Merge branch 'devel' into dev/commRefactoringNG
# Conflicts: # src/octoprint/logging/handlers.py # src/octoprint/printer/standard.py
This commit is contained in:
commit
812ce40e35
28 files changed
+3089
-1761
No files matched your search
+46
-6
@@ -229,7 +229,7 @@ Issue a print head command
|
||||
feedrate
|
||||
Changes the feedrate factor to apply to the movements of the axes.
|
||||
|
||||
* ``factor``: The new factor, percentage as integer or float (percentage divided by 100) between 50 and 200%.
|
||||
* ``factor``: The new factor, percentage between 50 and 200% as integer (``50`` to ``200``) or float (``0.5`` to ``2.0``).
|
||||
|
||||
All of these commands except ``feedrate`` may only be sent if the printer is currently operational and not printing.
|
||||
Otherwise a :http:statuscode:`409` is returned.
|
||||
@@ -280,9 +280,9 @@ Issue a print head command
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example feed rate request**
|
||||
**Example feed rate request (1/2)**
|
||||
|
||||
Set the feed rate factor to 105%.
|
||||
Set the feed rate factor to 105% using an integer argument.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@@ -300,6 +300,26 @@ Issue a print head command
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example feed rate request (2/2)**
|
||||
|
||||
Set the feed rate factor to 105% using a float argument.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/printhead HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "feedrate",
|
||||
"factor": 1.05
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``jog`` or ``home``.
|
||||
:json number x: ``jog`` command: The amount to travel on the X axis in mm.
|
||||
:json number y: ``jog`` command: The amount to travel on the Y axis in mm.
|
||||
@@ -346,7 +366,7 @@ Issue a tool command
|
||||
flowrate
|
||||
Changes the flow rate factor to apply to extrusion of the tool.
|
||||
|
||||
* ``factor``: The new factor, percentage as integer or float (percentage divided by 100) between 75 and 125%.
|
||||
* ``factor``: The new factor, percentage between 75 and 125% as integer (``75`` to ``125``) or float (``0.75`` to ``1.25``).
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational and -- in case of ``select`` and
|
||||
``extrude`` -- not printing. Otherwise a :http:statuscode:`409` is returned.
|
||||
@@ -461,9 +481,9 @@ Issue a tool command
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example flow rate request**
|
||||
**Example flow rate request (1/2)**
|
||||
|
||||
Set the flow rate factor to 95%.
|
||||
Set the flow rate factor to 95% using an integer attribute.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@@ -481,6 +501,26 @@ Issue a tool command
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example flow rate request (2/2)**
|
||||
|
||||
Set the flow rate factor to 95% using a float attribute.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "flowrate",
|
||||
"factor": 0.95
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``target``, ``offset``, ``select`` or ``extrude``.
|
||||
:json object targets: ``target`` command: The target temperatures to set. Valid properties have to match the format ``tool{n}``.
|
||||
:json object offsets: ``offset`` command: The offset temperature to set. Valid properties have to match the format ``tool{n}``.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
.. _sec-bundledplugins-action_command_prompt:
|
||||
|
||||
Action Command Prompt support
|
||||
=============================
|
||||
|
||||
The OctoPrint Action Command Prompt Support Plugin comes bundled with OctoPrint (starting with 1.3.9).
|
||||
|
||||
It allows firmware to trigger dialog prompts for logged in users using :ref:`action commands <sec-features-action_commands>`, e.g. to wait
|
||||
for user acknowledgement or allow the user to choose between options, and also to close the dialog again
|
||||
in case its no longer needed, e.g. due to the user proceeding on the printer's own controller.
|
||||
|
||||
The choice of the user can be communicated back to the firmware via a configurable GCODE command with a
|
||||
placeholder for the selected option's index.
|
||||
|
||||
.. _fig-bundledplugins-action_command_prompt-example:
|
||||
.. figure:: ../images/bundledplugins-action_command_prompt-example.png
|
||||
:align: center
|
||||
:alt: Simple prompt example
|
||||
|
||||
A simple dialog example triggered by the firmware
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-firststeps:
|
||||
|
||||
First Steps
|
||||
-----------
|
||||
|
||||
In order for this plugin to work, you'll need to configure it with the command your firmware uses to accept
|
||||
dialog selections. You can do that in the settings dialog.
|
||||
|
||||
Currently there is no agreed upon command for this since no firmware has yet made use of this feature, so OctoPrint
|
||||
ships with an empty value here.
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-configuration:
|
||||
|
||||
Configuring the plugin
|
||||
----------------------
|
||||
|
||||
The plugin supports the following configuration keys:
|
||||
|
||||
* ``selection_command``: The command to send to the firmware on choice, including the ``{choice}`` placeholder, e.g. ``M876 S{choice}``.
|
||||
|
||||
You can modify them either through the plugin's configuration dialog under Settings, or by directly editing ``config.yaml``.
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-action_commands:
|
||||
|
||||
Supported action commands
|
||||
-------------------------
|
||||
|
||||
prompt_begin <message>
|
||||
Starts the definition of a prompt dialog. ``<message>`` is the message to display to the user. Will be ignored
|
||||
if a dialog is already defined.
|
||||
|
||||
prompt_choice <text>
|
||||
Defines a choice with the associated ``<text>``. Will be ignored if no dialog has been defined yet.
|
||||
|
||||
prompt_button <text>
|
||||
Same as ``prompt_choice``.
|
||||
|
||||
prompt_show
|
||||
Tells OctoPrint that the dialog is now fully defined and to prompt the user. Will be ignored if no dialog is
|
||||
defined yet.
|
||||
|
||||
prompt_end
|
||||
Tells OctoPrint that the dialog should now be closed (e.g. the user made the choice on the printer directly instead
|
||||
of through OctoPrint). Will be ignored if no dialog is defined yet.
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-example:
|
||||
|
||||
Example communication with the firmware
|
||||
---------------------------------------
|
||||
|
||||
.. _sec-bundledplugins-action_command_prompt-sourcecode:
|
||||
|
||||
To display the :ref:`above dialog <fig-bundledplugins-action_command_prompt-example>` the firmware sent these action commands:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
//action:prompt_begin Filament unloaded, swap then proceed
|
||||
//action:prompt_choice Filament swapped
|
||||
//action:prompt_show
|
||||
|
||||
If the user clicks the button, assuming a ``selection_command`` of ``M876 S{choice}`` is configured, OctoPrint
|
||||
will send back ``M876 S0`` (0-based index).
|
||||
|
||||
A more complicated example with three options would be the following:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
//action:prompt_begin Filament runout detected. Please choose how to proceed:
|
||||
//action:prompt_choice Swap filament
|
||||
//action:prompt_choice Home X/Y and pause print
|
||||
//action:prompt_choice Abort print
|
||||
//action:prompt_show
|
||||
|
||||
This would produce the following output:
|
||||
|
||||
.. _fig-bundledplugins-action_command_prompt-example2:
|
||||
.. figure:: ../images/bundledplugins-action_command_prompt-example2.png
|
||||
:align: center
|
||||
:alt: Another prompt example
|
||||
|
||||
Another dialog example triggered by the firmware
|
||||
|
||||
If the user selects "Abort print", OctoPrint will send ``2`` as selected choice.
|
||||
|
||||
Source code
|
||||
-----------
|
||||
|
||||
The source of the Action Command Prompt Support plugin is bundled with OctoPrint and can be found in
|
||||
its source repository under ``src/octoprint/plugins/action_command_prompt``.
|
||||
@@ -7,6 +7,7 @@ Bundled Plugins
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
action_command_prompt.rst
|
||||
cura.rst
|
||||
discovery.rst
|
||||
logging.rst
|
||||
|
||||
@@ -29,12 +29,27 @@ pause
|
||||
When this command is received from the printer, OctoPrint will pause a current print job just like if the
|
||||
"Pause" button had been clicked.
|
||||
|
||||
paused
|
||||
When this command is received from the printer, OctoPrint will pause a current print job but *without* triggering
|
||||
any GCODE scripts or sending SD print control commands to the printer. This might be interesting for firmware
|
||||
that wants to signal to OctoPrint that a print should be paused but without any control interference from
|
||||
OctoPrint, e.g. in case of a filament change fully managed by the firmware.
|
||||
|
||||
resume
|
||||
When this command is received from the printer, OctoPrint will resume a current print job just like if
|
||||
the "Resume" button had been clicked.
|
||||
|
||||
resumed
|
||||
When this command is received from the printer, OctoPrint will resume a current print job but *without* triggering
|
||||
any GCODE scripts or sending SD print control commands to the printer. This might be interesting for firmware
|
||||
that wants to signal to OctoPrint that a print should be resumed but without any control interference from
|
||||
OctoPrint, e.g. in case of a filament change fully managed by the firmware.
|
||||
|
||||
disconnect
|
||||
When this command is received from the printer, OctoPrint will immediately disconnect from it.
|
||||
|
||||
If the bundled :ref:`Action Command Prompt Support Plugin <sec-bundledplugins-action_command_prompt>` is enabled (which
|
||||
should be the case by default), OctoPrint will also interactive dialog creation through its :ref:`supported commands <sec-bundledplugins-action_command_prompt-action_commands>`.
|
||||
|
||||
Support for additional commands may be added by plugins by implementing a handler for the
|
||||
:ref:`octoprint.comm.protocol.action <sec-plugins-hook-comm-protocol-action>` hook.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
+47
-1
@@ -380,6 +380,52 @@ octoprint.cli.commands
|
||||
OctoPrint's CLI.
|
||||
:rtype: list
|
||||
|
||||
.. _sec-plugins-hook-comm-firmware-info:
|
||||
|
||||
octoprint.comm.firmware.info
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: firmware_info_hook(comm_instance, firmware_name, firmware_data, *args, **kwargs)
|
||||
|
||||
Be notified of firmware information received from the printer following an ``M115``.
|
||||
|
||||
Hook handlers may use this to react/adjust behaviour based on reported firmware data. OctoPrint parses the received
|
||||
report line and provides the parsed ``firmware_name`` and additional ``firmware_data`` contained therein. A
|
||||
response line ``FIRMWARE_NAME:Some Firmware Name FIRMWARE_VERSION:1.2.3 PROTOCOL_VERSION:1.0`` for example will
|
||||
be turned into a ``dict`` looking like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
dict(FIRMWARE_NAME="Some Firmware Name",
|
||||
FIRMWARE_VERSION="1.2.3",
|
||||
PROTOCOL_VERSION="1.0")
|
||||
|
||||
``firmware_name`` will be ``Some Firmware Name`` in this case.
|
||||
|
||||
:param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
|
||||
:param str firmware_name: The name of the parsed capability
|
||||
:param dict firmware_data: All data contained in the ``M115`` report
|
||||
|
||||
.. _sec-plugins-hook-comm-firmware-capabilities:
|
||||
|
||||
octoprint.comm.firmware.capabilities
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: firmware_capability_hook(comm_instance, capability, enabled, already_defined, *args, **kwargs)
|
||||
|
||||
Be notified of capability report entries received from the printer.
|
||||
|
||||
Hook handlers may use this to react to custom firmware capabilities. OctoPrint parses the received capability
|
||||
line and provides the parsed ``capability`` and whether it's ``enabled`` to the handler. Additionally all already
|
||||
parsed capabilities will also be provided.
|
||||
|
||||
Note that hook handlers will be called once per received capability line.
|
||||
|
||||
:param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
|
||||
:param str capability: The name of the parsed capability
|
||||
:param bool enabled: Whether the capability is reported as enabled or disabled
|
||||
:param dict already_defined: Already defined capabilities (capability name mapped to enabled flag)
|
||||
|
||||
.. _sec-plugins-hook-comm-protocol-action:
|
||||
|
||||
octoprint.comm.protocol.action
|
||||
@@ -389,7 +435,7 @@ octoprint.comm.protocol.action
|
||||
|
||||
React to a :ref:`action command <sec-features-action_commands>` received from the printer.
|
||||
|
||||
Hook handlers may use this to react to react to custom firmware messages. OctoPrint parses the received action
|
||||
Hook handlers may use this to react to custom firmware messages. OctoPrint parses the received action
|
||||
command ``line`` and provides the parsed ``action`` (so anything after ``// action:``) to the hook handler.
|
||||
|
||||
No returned value is expected.
|
||||
|
||||
@@ -38,8 +38,7 @@ INSTALL_REQUIRES = [
|
||||
"pkginfo>=1.4.2,<1.5",
|
||||
"requests>=2.18.4,<3",
|
||||
"semantic_version>=2.6.0,<2.7",
|
||||
"psutil==5.4.3", # 5.4.4 introduced a breaking change concerning installing under non current
|
||||
# setuptools versions. Pinning to 5.4.3 for now to work around this.
|
||||
"psutil>=5.4.5,<5.5",
|
||||
"Click>=6.7,<6.8",
|
||||
"awesome-slugify>=1.6.5,<1.7",
|
||||
"feedparser>=5.2.1,<5.3",
|
||||
|
||||
@@ -400,10 +400,10 @@ class SDFilePrintjob(StoragePrintjob, FileAwareProtocolListener):
|
||||
|
||||
class PrintjobListener(object):
|
||||
|
||||
def on_job_started(self, job):
|
||||
def on_job_started(self, job, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_job_done(self, job):
|
||||
def on_job_done(self, job, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_job_failed(self, job):
|
||||
@@ -412,13 +412,13 @@ class PrintjobListener(object):
|
||||
def on_job_cancelling(self, job, firmware_error=None):
|
||||
pass
|
||||
|
||||
def on_job_cancelled(self, job, cancel_position=None):
|
||||
def on_job_cancelled(self, job, cancel_position=None, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_job_paused(self, job, pause_position=None):
|
||||
def on_job_paused(self, job, pause_position=None, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_job_resumed(self, job):
|
||||
def on_job_resumed(self, job, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_job_progress(self, job):
|
||||
|
||||
@@ -630,30 +630,46 @@ class PluginManager(object):
|
||||
def plugin_hooks(self):
|
||||
return {key: map(lambda v: (v[1], v[2]), value) for key, value in self._plugin_hooks.items()}
|
||||
|
||||
def find_plugins(self, existing=None, ignore_uninstalled=True):
|
||||
def find_plugins(self, existing=None, ignore_uninstalled=True, incl_all_found=False):
|
||||
added, found = self._find_plugins(existing=existing, ignore_uninstalled=ignore_uninstalled)
|
||||
if incl_all_found:
|
||||
return added, found
|
||||
else:
|
||||
return added
|
||||
|
||||
def _find_plugins(self, existing=None, ignore_uninstalled=True):
|
||||
if existing is None:
|
||||
existing = dict(self.plugins)
|
||||
|
||||
result = OrderedDict()
|
||||
result_added = OrderedDict()
|
||||
result_found = []
|
||||
|
||||
if self.plugin_folders:
|
||||
try:
|
||||
result.update(self._find_plugins_from_folders(self.plugin_folders,
|
||||
existing,
|
||||
ignored_uninstalled=ignore_uninstalled))
|
||||
added, found = self._find_plugins_from_folders(self.plugin_folders,
|
||||
existing,
|
||||
ignored_uninstalled=ignore_uninstalled)
|
||||
result_added.update(added)
|
||||
result_found += found
|
||||
except:
|
||||
self.logger.exception("Error fetching plugins from folders")
|
||||
|
||||
if self.plugin_entry_points:
|
||||
existing.update(result)
|
||||
existing.update(result_added)
|
||||
try:
|
||||
result.update(self._find_plugins_from_entry_points(self.plugin_entry_points,
|
||||
existing,
|
||||
ignore_uninstalled=ignore_uninstalled))
|
||||
added, found = self._find_plugins_from_entry_points(self.plugin_entry_points,
|
||||
existing,
|
||||
ignore_uninstalled=ignore_uninstalled)
|
||||
result_added.update(added)
|
||||
result_found += found
|
||||
except:
|
||||
self.logger.exception("Error fetching plugins from entry points")
|
||||
return result
|
||||
|
||||
return result_added, result_found
|
||||
|
||||
def _find_plugins_from_folders(self, folders, existing, ignored_uninstalled=True):
|
||||
result = OrderedDict()
|
||||
added = OrderedDict()
|
||||
found = []
|
||||
|
||||
for folder in folders:
|
||||
try:
|
||||
@@ -691,7 +707,8 @@ class PluginManager(object):
|
||||
# whatever this is, we ignore it
|
||||
continue
|
||||
|
||||
if key in existing or key in result or (ignored_uninstalled and key in self.marked_plugins["uninstalled"]):
|
||||
found.append(key)
|
||||
if key in existing or key in added or (ignored_uninstalled and key in self.marked_plugins["uninstalled"]):
|
||||
# plugin is already defined, ignore it
|
||||
continue
|
||||
|
||||
@@ -702,16 +719,17 @@ class PluginManager(object):
|
||||
plugin.origin = FolderOrigin("folder", folder)
|
||||
plugin.managable = not flagged_readonly and not actual_readonly
|
||||
plugin.enabled = False
|
||||
result[key] = plugin
|
||||
added[key] = plugin
|
||||
except:
|
||||
self.logger.exception("Error processing folder entry {!r} from folder {}".format(entry, folder))
|
||||
except:
|
||||
self.logger.exception("Error processing folder {}".format(folder))
|
||||
|
||||
return result
|
||||
return added, found
|
||||
|
||||
def _find_plugins_from_entry_points(self, groups, existing, ignore_uninstalled=True):
|
||||
result = OrderedDict()
|
||||
added = OrderedDict()
|
||||
found = []
|
||||
|
||||
# let's make sure we have a current working set ...
|
||||
working_set = pkg_resources.WorkingSet()
|
||||
@@ -745,7 +763,8 @@ class PluginManager(object):
|
||||
module_name = entry_point.module_name
|
||||
version = entry_point.dist.version
|
||||
|
||||
if key in existing or key in result or (ignore_uninstalled and key in self.marked_plugins["uninstalled"]):
|
||||
found.append(key)
|
||||
if key in existing or key in added or (ignore_uninstalled and key in self.marked_plugins["uninstalled"]):
|
||||
# plugin is already defined or marked as uninstalled, ignore it
|
||||
continue
|
||||
|
||||
@@ -782,11 +801,11 @@ class PluginManager(object):
|
||||
module_name,
|
||||
plugin.location))
|
||||
|
||||
result[key] = plugin
|
||||
added[key] = plugin
|
||||
except:
|
||||
self.logger.exception("Error processing entry point {!r} for group {}".format(entry_point, group))
|
||||
|
||||
return result
|
||||
return added, found
|
||||
|
||||
def _import_plugin_from_module(self, key, folder=None, module_name=None, name=None, version=None, summary=None,
|
||||
author=None, url=None, license=None, bundled=False):
|
||||
@@ -869,11 +888,26 @@ class PluginManager(object):
|
||||
if force_reload is None:
|
||||
force_reload = []
|
||||
|
||||
plugins = self.find_plugins(existing=dict((k, v) for k, v in self.plugins.items() if not k in force_reload))
|
||||
self.disabled_plugins.update(plugins)
|
||||
added, found = self.find_plugins(existing=dict((k, v) for k, v in self.plugins.items() if not k in force_reload),
|
||||
incl_all_found=True)
|
||||
|
||||
# let's clean everything we DIDN'T find first
|
||||
removed = [key for key in self.enabled_plugins.keys() + self.disabled_plugins.keys() if key not in found]
|
||||
for key in removed:
|
||||
try:
|
||||
del self.enabled_plugins[key]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
del self.disabled_plugins[key]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
self.disabled_plugins.update(added)
|
||||
|
||||
# 1st pass: loading the plugins
|
||||
for name, plugin in plugins.items():
|
||||
for name, plugin in added.items():
|
||||
try:
|
||||
if not plugin.blacklisted and not plugin.forced_disabled:
|
||||
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
|
||||
@@ -887,7 +921,7 @@ class PluginManager(object):
|
||||
force_reload=force_reload)
|
||||
|
||||
# 2nd pass: enabling those plugins that need enabling
|
||||
for name, plugin in plugins.items():
|
||||
for name, plugin in added.items():
|
||||
try:
|
||||
if plugin.loaded and not plugin.forced_disabled:
|
||||
if plugin.blacklisted:
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
from octoprint.server import user_permission
|
||||
|
||||
import flask
|
||||
from flask_babel import gettext
|
||||
|
||||
class Prompt(object):
|
||||
|
||||
def __init__(self, text):
|
||||
self.text = text
|
||||
self.choices = []
|
||||
|
||||
self._active = False
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
return self._active
|
||||
|
||||
def add_choice(self, text):
|
||||
self.choices.append(text)
|
||||
|
||||
def activate(self):
|
||||
self._active = True
|
||||
|
||||
def validate_choice(self, choice):
|
||||
return 0 <= choice < len(self.choices)
|
||||
|
||||
|
||||
class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.TemplatePlugin):
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
def __init__(self):
|
||||
self._prompt = None
|
||||
self._selection_command = None
|
||||
|
||||
def initialize(self):
|
||||
self._selection_command = self._settings.get([b"selection_command"])
|
||||
|
||||
#~ AssetPlugin
|
||||
|
||||
def get_assets(self):
|
||||
return dict(js=["js/action_command_prompt.js"])
|
||||
|
||||
#~ SettingsPlugin
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(selection_command=None)
|
||||
|
||||
def on_settings_save(self, data):
|
||||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
||||
self._selection_command = self._settings.get([b"selection_command"])
|
||||
|
||||
#~ SimpleApiPlugin
|
||||
|
||||
def get_api_commands(self):
|
||||
return dict(select=["choice"])
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
if command == "select":
|
||||
if not user_permission.can():
|
||||
return flask.abort(403, "Insufficient permissions")
|
||||
|
||||
if self._prompt is None:
|
||||
return flask.abort(409, "No active prompt")
|
||||
|
||||
choice = data["choice"]
|
||||
if not isinstance(choice, int) or not self._prompt.validate_choice(choice):
|
||||
return flask.abort(400, "{!r} is not a valid value for choice".format(choice))
|
||||
|
||||
self._answer_prompt(choice)
|
||||
|
||||
def on_api_get(self, request):
|
||||
if not user_permission.can():
|
||||
return flask.abort(403, "Insufficient permissions")
|
||||
if self._prompt is None:
|
||||
return flask.jsonify()
|
||||
else:
|
||||
return flask.jsonify(text=self._prompt.text, choices=self._prompt.choices)
|
||||
|
||||
#~ TemplatePlugin
|
||||
|
||||
def get_template_configs(self):
|
||||
return [dict(type="settings", name=gettext("Action Command Prompt"), custom_bindings=False)]
|
||||
|
||||
#~ action command handler
|
||||
|
||||
def action_command_handler(self, comm, line, action, *args, **kwargs):
|
||||
if not action.startswith(b"prompt_"):
|
||||
return
|
||||
|
||||
if self._selection_command is None:
|
||||
self._logger.info("Got a prompt command from the printer but no selection command is defined")
|
||||
return
|
||||
|
||||
parts = action.split(None, 1)
|
||||
if len(parts) == 1:
|
||||
action = parts[0]
|
||||
parameter = b""
|
||||
else:
|
||||
action, parameter = parts
|
||||
|
||||
if action == b"prompt_begin":
|
||||
if self._prompt is not None and self._prompt.active:
|
||||
self._logger.warn("Prompt is already defined")
|
||||
return
|
||||
self._prompt = Prompt(parameter.strip())
|
||||
|
||||
elif action == b"prompt_choice" or action == b"prompt_button":
|
||||
if self._prompt is None:
|
||||
return
|
||||
if self._prompt.active:
|
||||
self._logger.warn("Prompt is already active")
|
||||
return
|
||||
self._prompt.add_choice(parameter.strip())
|
||||
|
||||
elif action == b"prompt_show":
|
||||
if self._prompt is None:
|
||||
return
|
||||
if self._prompt.active:
|
||||
self._logger.warn("Prompt is already active")
|
||||
return
|
||||
self._show_prompt()
|
||||
|
||||
elif action == b"prompt_end":
|
||||
if self._prompt is None:
|
||||
return
|
||||
self._close_prompt()
|
||||
self._prompt = None
|
||||
|
||||
#~ prompt handling
|
||||
|
||||
def _show_prompt(self):
|
||||
self._prompt.activate()
|
||||
self._plugin_manager.send_plugin_message(self._identifier, dict(action="show",
|
||||
text=self._prompt.text,
|
||||
choices=self._prompt.choices))
|
||||
|
||||
def _close_prompt(self):
|
||||
self._prompt = None
|
||||
self._plugin_manager.send_plugin_message(self._identifier, dict(action="close"))
|
||||
|
||||
def _answer_prompt(self, choice):
|
||||
self._close_prompt()
|
||||
self._printer.commands([self._selection_command.format(choice=choice)])
|
||||
|
||||
|
||||
__plugin_name__ = "Action Command Prompt Support"
|
||||
__plugin_description__ = "Allows your printer to trigger prompts via action commands on the connection"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin your printer will no longer be able to trigger"
|
||||
"confirmation or selection prompts in OctoPrint")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = ActionCommandPromptPlugin()
|
||||
__plugin_hooks__ = {
|
||||
b"octoprint.comm.protocol.action": __plugin_implementation__.action_command_handler
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(global.OctoPrintClient);
|
||||
}
|
||||
})(this, function(OctoPrintClient) {
|
||||
var OctoPrintActionCommandPromptClient = function(base) {
|
||||
this.base = base;
|
||||
};
|
||||
|
||||
OctoPrintActionCommandPromptClient.prototype.get = function(refresh, opts) {
|
||||
return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"), opts);
|
||||
};
|
||||
|
||||
OctoPrintActionCommandPromptClient.prototype.select = function(choice, opts) {
|
||||
var data = {
|
||||
choice: choice
|
||||
};
|
||||
return this.base.simpleApiCommand("action_command_prompt", "select", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintClient.registerPluginComponent("action_command_prompt", OctoPrintActionCommandPromptClient);
|
||||
return OctoPrintActionCommandPromptClient;
|
||||
});
|
||||
|
||||
$(function() {
|
||||
function ActionCommandPromptViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
|
||||
self._modal = undefined;
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.loginState.isUser()) return;
|
||||
|
||||
OctoPrint.plugins.action_command_prompt.get()
|
||||
.done(self.fromResponse);
|
||||
};
|
||||
|
||||
self.fromResponse = function(data) {
|
||||
if (data.hasOwnProperty("text") && data.hasOwnProperty("choices")) {
|
||||
self._showPrompt(data.text, data.choices);
|
||||
}
|
||||
};
|
||||
|
||||
self._showPrompt = function(text, buttons) {
|
||||
var opts = {
|
||||
title: gettext("Message from your printer"),
|
||||
message: text,
|
||||
selections: buttons,
|
||||
onselect: function(index) {
|
||||
if (index > -1) {
|
||||
self._select(index);
|
||||
}
|
||||
},
|
||||
onclose: function() {
|
||||
self._modal = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
self._modal = showSelectionDialog(opts)
|
||||
};
|
||||
|
||||
self._select = function(index) {
|
||||
OctoPrint.plugins.action_command_prompt.select(index);
|
||||
};
|
||||
|
||||
self._closePrompt = function() {
|
||||
if (self._modal) {
|
||||
self._modal.modal("hide");
|
||||
}
|
||||
};
|
||||
|
||||
self.onStartupComplete = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
self.onDataUpdaterPluginMessage = function(plugin, data) {
|
||||
if (!self.loginState.isUser()) return;
|
||||
if (plugin !== "action_command_prompt") {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (data.action) {
|
||||
case "show": {
|
||||
self._showPrompt(data.text, data.choices);
|
||||
break;
|
||||
}
|
||||
case "close": {
|
||||
self._closePrompt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ActionCommandPromptViewModel,
|
||||
dependencies: ["loginStateViewModel"]
|
||||
});
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<h3>{{ _('Action Command Prompt Settings') }}</h3>
|
||||
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Selection Command') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.action_command_prompt.selection_command">
|
||||
<div class="help-block">{{ _('Use this to define the command to tell the printer about the selection. OctoPrint will replace <code>{choice}</code> with the index of the selected choice. E.g. <code>M876 S{choice}</code> will become <code>M123 S1</code>') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -9,6 +9,7 @@ import octoprint.plugin
|
||||
from octoprint.events import Events
|
||||
from octoprint.access import USER_GROUP
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.util.version import get_comparable_version
|
||||
|
||||
import flask
|
||||
from flask_babel import gettext
|
||||
@@ -39,13 +40,32 @@ CR10S_RECEIVED_TEST = lambda line: line and CR10S_AUTHOR in line.lower()
|
||||
# Malyan M200 aka Monoprice Select Mini
|
||||
MALYANM200_M115_TEST = lambda name, data: name and name.lower().startswith("malyan") and data.get("MODEL") == "M200"
|
||||
|
||||
# Any Repetier versions < 0.92
|
||||
REPETIER_BEFORE_092_M115_TEST = lambda name, data: name and name.lower().startswith("repetier") and extract_repetier_version(name) is not None and extract_repetier_version(name) < get_comparable_version("0.92")
|
||||
|
||||
# THERMAL_PROTECTION capability reported as disabled
|
||||
THERMAL_PROTECTION_CAP_TEST = lambda cap, enabled: cap == "THERMAL_PROTECTION" and not enabled
|
||||
|
||||
SAFETY_CHECKS = {
|
||||
"firmware-unsafe": dict(m115=(ANETA8_M115_TEST, MALYANM200_M115_TEST),
|
||||
"firmware-unsafe": dict(m115=(ANETA8_M115_TEST, MALYANM200_M115_TEST, REPETIER_BEFORE_092_M115_TEST),
|
||||
received=(ANYCUBIC_RECEIVED_TEST, CR10S_RECEIVED_TEST),
|
||||
cap=(THERMAL_PROTECTION_CAP_TEST,),
|
||||
message=u"Your printer's firmware is known to lack mandatory safety features (e.g. " \
|
||||
u"thermal runaway protection). This is a fire risk.")
|
||||
}
|
||||
|
||||
def extract_repetier_version(name):
|
||||
"""
|
||||
Extracts the Repetier version number from the firmware name.
|
||||
|
||||
Example: "Repetier_0.91" => 0.91
|
||||
"""
|
||||
version = None
|
||||
if "_" in name:
|
||||
_, version = name.split("_", 1)
|
||||
version = get_comparable_version(version, base=True)
|
||||
return version
|
||||
|
||||
class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin,
|
||||
octoprint.plugin.SimpleApiPlugin,
|
||||
@@ -77,10 +97,7 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
|
||||
##~~ EventHandlerPlugin API
|
||||
|
||||
def on_event(self, event, payload):
|
||||
if event == Events.FIRMWARE_DATA:
|
||||
self._run_checks("m115", payload.get("name"), payload.get("data"))
|
||||
self._scan_received = False
|
||||
elif event == Events.DISCONNECTED:
|
||||
if event == Events.DISCONNECTED:
|
||||
self._reset_warnings()
|
||||
|
||||
##~~ SimpleApiPlugin API
|
||||
@@ -97,7 +114,18 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
|
||||
self._run_checks("received", line)
|
||||
return line
|
||||
|
||||
# Additional permissions hook
|
||||
##~~ Firmware info hook handler
|
||||
|
||||
def on_firmware_info_received(self, comm_instance, firmware_name, firmware_data):
|
||||
self._run_checks("m115", firmware_name, firmware_data)
|
||||
self._scan_received = False
|
||||
|
||||
##~~ Firmware capability hook handler
|
||||
|
||||
def on_firmware_cap_received(self, comm_instance, cap, enabled, all_caps):
|
||||
self._run_checks("cap", cap, enabled)
|
||||
|
||||
##~~ Additional permissions hook handler
|
||||
|
||||
def get_additional_permissions(self):
|
||||
return [
|
||||
@@ -154,6 +182,8 @@ __plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = PrinterSafetyCheckPlugin()
|
||||
__plugin_hooks__ = {
|
||||
"octoprint.comm.protocol.gcode.received": __plugin_implementation__.on_gcode_received,
|
||||
"octoprint.comm.protocol.firmware.info": __plugin_implementation__.on_firmware_info_received,
|
||||
"octoprint.comm.protocol.firmware.capabilities": __plugin_implementation__.on_firmware_cap_received,
|
||||
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
import re
|
||||
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import deprecated
|
||||
from octoprint.util import deprecated, natural_key
|
||||
from octoprint.filemanager import FileDestinations
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@ class PrinterInterface(object):
|
||||
"""
|
||||
import octoprint.util.comm as comm
|
||||
return {
|
||||
"ports": comm.serialList(),
|
||||
"baudrates": comm.baudrateList(),
|
||||
"ports": sorted(comm.serialList(), key=natural_key),
|
||||
"baudrates": sorted(comm.baudrateList(), reverse=True),
|
||||
"portPreference": settings().get(["serial", "port"]),
|
||||
"baudratePreference": settings().getInt(["serial", "baudrate"]),
|
||||
"autoconnect": settings().getBoolean(["serial", "autoconnect"])
|
||||
|
||||
@@ -39,7 +39,10 @@ class PrintTimeEstimator(object):
|
||||
if self._job_type == "sdcard":
|
||||
# we are interesting in a rolling window of roughly the last 15s, so the number of entries has to be derived
|
||||
# by that divided by the sd status polling interval
|
||||
rolling_window = 15 / settings().get(["serial", "timeout", "sdStatus"])
|
||||
interval = settings().getFloat(["serial", "timeout", "sdStatus"])
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
rolling_window = 15 / interval
|
||||
|
||||
# we are happy when one rolling window has been stable
|
||||
countdown = rolling_window
|
||||
|
||||
@@ -695,6 +695,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
def is_paused(self, *args, **kwargs):
|
||||
return self._protocol is not None and self._protocol.state == ProtocolState.PAUSED
|
||||
|
||||
def is_resuming(self, *args, **kwargs):
|
||||
return self._comm is not None and self._comm.isResuming()
|
||||
|
||||
def is_finishing(self, *args, **kwargs):
|
||||
return self._comm is not None and self._comm.isFinishing()
|
||||
|
||||
def is_error(self, *args, **kwargs):
|
||||
return self._protocol is not None and self._protocol.state == ProtocolState.DISCONNECTED_WITH_ERROR
|
||||
|
||||
@@ -991,15 +997,17 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
self._logger.exception("Error while trying to send initial state update")
|
||||
|
||||
def _get_state_flags(self):
|
||||
return dict(operational=self.is_operational(),
|
||||
printing=self.is_printing(),
|
||||
cancelling=self.is_cancelling(),
|
||||
pausing=self.is_pausing(),
|
||||
closedOrError=self.is_closed_or_error(),
|
||||
error=self.is_error(),
|
||||
paused=self.is_paused(),
|
||||
ready=self.is_ready(),
|
||||
sdReady=self.is_sd_ready())
|
||||
return self._dict(operational=self.is_operational(),
|
||||
printing=self.is_printing(),
|
||||
cancelling=self.is_cancelling(),
|
||||
pausing=self.is_pausing(),
|
||||
resuming=self.is_resuming(),
|
||||
finishing=self.is_finishing(),
|
||||
closedOrError=self.is_closed_or_error(),
|
||||
error=self.is_error(),
|
||||
paused=self.is_paused(),
|
||||
ready=self.is_ready(),
|
||||
sdReady=self.is_sd_ready())
|
||||
|
||||
def _get_origin_for_job(self, job=None):
|
||||
if job is None:
|
||||
@@ -1096,18 +1104,19 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
|
||||
self._state_monitor.trigger_progress_update()
|
||||
|
||||
def on_job_started(self, job):
|
||||
def on_job_started(self, job, suppress_script=False):
|
||||
if self._job is None or job != self._job.job:
|
||||
return
|
||||
|
||||
payload = job.event_payload()
|
||||
if payload:
|
||||
eventManager().fire(Events.PRINT_STARTED, payload)
|
||||
self.script("beforePrintStarted",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
if not suppress_script:
|
||||
self.script("beforePrintStarted",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
|
||||
def on_job_done(self, job):
|
||||
def on_job_done(self, job, suppress_script=False):
|
||||
if self._job is None or job != self._job.job:
|
||||
return
|
||||
|
||||
@@ -1137,9 +1146,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
flags=self._get_state_flags()))
|
||||
|
||||
eventManager().fire(Events.PRINT_DONE, payload)
|
||||
self.script("afterPrintDone",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
if not suppress_script:
|
||||
self.script("afterPrintDone",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
|
||||
def log_print():
|
||||
self._file_manager.log_print(payload["origin"],
|
||||
@@ -1172,7 +1182,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
payload["firmwareError"] = firmware_error
|
||||
eventManager().fire(Events.PRINT_CANCELLING, payload)
|
||||
|
||||
def on_job_cancelled(self, job, cancel_position=None):
|
||||
def on_job_cancelled(self, job, cancel_position=None, suppress_script=False):
|
||||
if self._job is None or job != self._job.job:
|
||||
return
|
||||
|
||||
@@ -1185,9 +1195,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
payload["position"] = cancel_position
|
||||
|
||||
eventManager().fire(Events.PRINT_CANCELLED, payload)
|
||||
self.script("afterPrintCancelled",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
if not suppress_script:
|
||||
self.script("afterPrintCancelled",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
|
||||
def finalize():
|
||||
self._file_manager.log_print(job.storage,
|
||||
@@ -1202,7 +1213,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def on_job_paused(self, job, pause_position=None):
|
||||
def on_job_paused(self, job, pause_position=None, suppress_script=False):
|
||||
if self._job is None or job != self._job.job:
|
||||
return
|
||||
|
||||
@@ -1211,20 +1222,22 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback, ProtocolListener,
|
||||
if pause_position:
|
||||
payload["position"] = pause_position
|
||||
eventManager().fire(Events.PRINT_PAUSED, payload)
|
||||
self.script("afterPrintPaused",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
if not suppress_script:
|
||||
self.script("afterPrintPaused",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
|
||||
def on_job_resumed(self, job):
|
||||
def on_job_resumed(self, job, suppress_script=False):
|
||||
if self._job is None or job != self._job.job:
|
||||
return
|
||||
|
||||
payload = job.event_payload()
|
||||
if payload:
|
||||
eventManager().fire(Events.PRINT_RESUMED, payload)
|
||||
self.script("beforePrintResumed",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
if not suppress_script:
|
||||
self.script("beforePrintResumed",
|
||||
context=dict(event=payload),
|
||||
must_be_set=False)
|
||||
|
||||
#~~ comm.MachineComPrintCallback implementation
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ def _get_options():
|
||||
default_profile = printerProfileManager.get_default()
|
||||
|
||||
options = dict(
|
||||
ports=sorted(connection_options["ports"]),
|
||||
baudrates=sorted(connection_options["baudrates"], reverse=True),
|
||||
ports=connection_options["ports"],
|
||||
baudrates=connection_options["baudrates"],
|
||||
printerProfiles=[dict(id=printer_profile["id"], name=printer_profile["name"] if "name" in printer_profile else printer_profile["id"]) for printer_profile in profile_options.values() if "id" in printer_profile],
|
||||
portPreference=connection_options["portPreference"],
|
||||
baudratePreference=connection_options["baudratePreference"],
|
||||
|
||||
@@ -385,17 +385,17 @@ def _saveSettings(data):
|
||||
if "autoconnect" in data["serial"]: s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"])
|
||||
if "port" in data["serial"]: s.set(["serial", "port"], data["serial"]["port"])
|
||||
if "baudrate" in data["serial"]: s.setInt(["serial", "baudrate"], data["serial"]["baudrate"])
|
||||
if "timeoutConnection" in data["serial"]: s.setFloat(["serial", "timeout", "connection"], data["serial"]["timeoutConnection"])
|
||||
if "timeoutDetection" in data["serial"]: s.setFloat(["serial", "timeout", "detection"], data["serial"]["timeoutDetection"])
|
||||
if "timeoutCommunication" in data["serial"]: s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunication"])
|
||||
if "timeoutCommunicationBusy" in data["serial"]: s.setFloat(["serial", "timeout", "communicationBusy"], data["serial"]["timeoutCommunicationBusy"])
|
||||
if "timeoutTemperature" in data["serial"]: s.setFloat(["serial", "timeout", "temperature"], data["serial"]["timeoutTemperature"])
|
||||
if "timeoutTemperatureTargetSet" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureTargetSet"], data["serial"]["timeoutTemperatureTargetSet"])
|
||||
if "timeoutTemperatureAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureAutoreport"], data["serial"]["timeoutTemperatureAutoreport"])
|
||||
if "timeoutSdStatus" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatus"], data["serial"]["timeoutSdStatus"])
|
||||
if "timeoutSdStatusAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatusAutoreport"], data["serial"]["timeoutSdStatusAutoreport"])
|
||||
if "timeoutBaudrateDetectionPause" in data["serial"]: s.setFloat(["serial", "timeout", "baudrateDetectionPause"], data["serial"]["timeoutBaudrateDetectionPause"])
|
||||
if "timeoutPositionLogWait" in data["serial"]: s.setFloat(["serial", "timeout", "positionLogWait"], data["serial"]["timeoutPositionLogWait"])
|
||||
if "timeoutConnection" in data["serial"]: s.setFloat(["serial", "timeout", "connection"], data["serial"]["timeoutConnection"], minimum=1.0)
|
||||
if "timeoutDetection" in data["serial"]: s.setFloat(["serial", "timeout", "detection"], data["serial"]["timeoutDetection"], minimum=1.0)
|
||||
if "timeoutCommunication" in data["serial"]: s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunication"], minimum=1.0)
|
||||
if "timeoutCommunicationBusy" in data["serial"]: s.setFloat(["serial", "timeout", "communicationBusy"], data["serial"]["timeoutCommunicationBusy"], minimum=1.0)
|
||||
if "timeoutTemperature" in data["serial"]: s.setFloat(["serial", "timeout", "temperature"], data["serial"]["timeoutTemperature"], minimum=1.0)
|
||||
if "timeoutTemperatureTargetSet" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureTargetSet"], data["serial"]["timeoutTemperatureTargetSet"], minimum=1.0)
|
||||
if "timeoutTemperatureAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureAutoreport"], data["serial"]["timeoutTemperatureAutoreport"], minimum=0.0)
|
||||
if "timeoutSdStatus" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatus"], data["serial"]["timeoutSdStatus"], minimum=1.0)
|
||||
if "timeoutSdStatusAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatusAutoreport"], data["serial"]["timeoutSdStatusAutoreport"], minimum=0.0)
|
||||
if "timeoutBaudrateDetectionPause" in data["serial"]: s.setFloat(["serial", "timeout", "baudrateDetectionPause"], data["serial"]["timeoutBaudrateDetectionPause"], minimum=0.0)
|
||||
if "timeoutPositionLogWait" in data["serial"]: s.setFloat(["serial", "timeout", "positionLogWait"], data["serial"]["timeoutPositionLogWait"], minimum=1.0)
|
||||
if "additionalPorts" in data["serial"] and isinstance(data["serial"]["additionalPorts"], (list, tuple)): s.set(["serial", "additionalPorts"], data["serial"]["additionalPorts"])
|
||||
if "additionalBaudrates" in data["serial"] and isinstance(data["serial"]["additionalBaudrates"], (list, tuple)): s.set(["serial", "additionalBaudrates"], data["serial"]["additionalBaudrates"])
|
||||
if "longRunningCommands" in data["serial"] and isinstance(data["serial"]["longRunningCommands"], (list, tuple)): s.set(["serial", "longRunningCommands"], data["serial"]["longRunningCommands"])
|
||||
|
||||
@@ -650,6 +650,7 @@ function showMessageDialog(msg, options) {
|
||||
var onclose = options.onclose || undefined;
|
||||
var onshow = options.onshow || undefined;
|
||||
var onshown = options.onshown || undefined;
|
||||
var nofade = options.nofade || false;
|
||||
|
||||
if (_.isString(message)) {
|
||||
message = $("<p>" + message + "</p>");
|
||||
@@ -660,7 +661,11 @@ function showMessageDialog(msg, options) {
|
||||
var modalFooter = $('<a href="javascript:void(0)" class="btn" data-dismiss="modal" aria-hidden="true">' + close + '</a>');
|
||||
|
||||
var modal = $('<div></div>')
|
||||
.addClass('modal hide fade')
|
||||
.addClass("modal hide");
|
||||
if (!nofade) {
|
||||
modal.addClass("fade");
|
||||
}
|
||||
modal
|
||||
.append($('<div></div>').addClass('modal-header').append(modalHeader))
|
||||
.append($('<div></div>').addClass('modal-body').append(modalBody))
|
||||
.append($('<div></div>').addClass('modal-footer').append(modalFooter));
|
||||
@@ -669,6 +674,7 @@ function showMessageDialog(msg, options) {
|
||||
if (onclose && _.isFunction(onclose)) {
|
||||
onclose();
|
||||
}
|
||||
modal.remove();
|
||||
});
|
||||
|
||||
if (onshow) {
|
||||
@@ -705,6 +711,7 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
var onproceed = options.onproceed || undefined;
|
||||
var onclose = options.onclose || undefined;
|
||||
var dialogClass = options.dialogClass || "";
|
||||
var nofade = options.nofade || false;
|
||||
|
||||
var modalHeader = $('<a href="javascript:void(0)" class="close" data-dismiss="modal" aria-hidden="true">×</a><h3>' + title + '</h3>');
|
||||
var modalBody;
|
||||
@@ -721,8 +728,11 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
.addClass("btn-" + proceedClass);
|
||||
|
||||
var modal = $('<div></div>')
|
||||
.addClass('modal hide fade')
|
||||
.addClass(dialogClass)
|
||||
.addClass('modal hide');
|
||||
if (!nofade) {
|
||||
modal.addClass('fade');
|
||||
}
|
||||
modal.addClass(dialogClass)
|
||||
.append($('<div></div>').addClass('modal-header').append(modalHeader))
|
||||
.append($('<div></div>').addClass('modal-body').append(modalBody))
|
||||
.append($('<div></div>').addClass('modal-footer').append(cancelButton).append(proceedButton));
|
||||
@@ -739,6 +749,108 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
onproceed(e);
|
||||
}
|
||||
modal.modal("hide");
|
||||
modal.remove();
|
||||
});
|
||||
|
||||
return modal;
|
||||
}
|
||||
|
||||
function showSelectionDialog(options) {
|
||||
var title = options.title;
|
||||
var message = options.message || undefined;
|
||||
var selections = options.selections || [];
|
||||
|
||||
var maycancel = options.maycancel || false;
|
||||
var cancel = options.cancel || undefined;
|
||||
var onselect = options.onselect || undefined;
|
||||
var onclose = options.onclose || undefined;
|
||||
var dialogClass = options.dialogClass || "";
|
||||
var nofade = options.nofade || false;
|
||||
|
||||
// header
|
||||
var modalHeader;
|
||||
if (maycancel) {
|
||||
modalHeader = $('<a href="javascript:void(0)" class="close" data-dismiss="modal" aria-hidden="true">×</a><h3>' + title + '</h3>');
|
||||
} else {
|
||||
modalHeader = $('<h3>' + title + '</h3>');
|
||||
}
|
||||
|
||||
// body
|
||||
var buttons = [];
|
||||
var selectionBody = $("<div></div>");
|
||||
var container;
|
||||
var additionalClass;
|
||||
|
||||
if (selections.length === 1) {
|
||||
container = selectionBody;
|
||||
additionalClass = "btn-block";
|
||||
} else if (selections.length === 2) {
|
||||
container = $("<div class='row-fluid'></div>");
|
||||
selectionBody.append(container);
|
||||
additionalClass = "span6"
|
||||
} else {
|
||||
container = $("<div class='row-fluid'></div>");
|
||||
selectionBody.append(container);
|
||||
additionalClass = "span6 offset3";
|
||||
}
|
||||
|
||||
_.each(selections, function(s, i) {
|
||||
var button = $('<button class="btn" data-index="' + i + '">' + selections[i] + '</button>');
|
||||
if (additionalClass) {
|
||||
button.addClass(additionalClass);
|
||||
}
|
||||
container.append(button);
|
||||
buttons.push(button);
|
||||
|
||||
if (selections.length > 2 && i < selections.length - 1) {
|
||||
container = $("<div class='row-fluid'></div>");
|
||||
selectionBody.append(container);
|
||||
}
|
||||
});
|
||||
|
||||
// divs
|
||||
var headerDiv = $('<div></div>').addClass('modal-header').append(modalHeader);
|
||||
|
||||
var bodyDiv = $('<div></div>').addClass('modal-body');
|
||||
if (message) {
|
||||
bodyDiv.append($('<p>' + message + '</p>'));
|
||||
}
|
||||
bodyDiv.append(selectionBody);
|
||||
|
||||
// create modal and do final wiring up
|
||||
var modal = $('<div></div>')
|
||||
.addClass('modal hide');
|
||||
if (!nofade) {
|
||||
modal.addClass('fade');
|
||||
}
|
||||
if (!cancel) {
|
||||
modal.data("backdrop", "static").data("keyboard", "false");
|
||||
}
|
||||
|
||||
modal.addClass(dialogClass)
|
||||
.append(headerDiv)
|
||||
.append(bodyDiv);
|
||||
modal.on('hidden', function(event) {
|
||||
if (onclose && _.isFunction(onclose)) {
|
||||
onclose(event);
|
||||
}
|
||||
modal.remove();
|
||||
});
|
||||
modal.modal("show");
|
||||
|
||||
_.each(buttons, function(button) {
|
||||
button.click(function(e) {
|
||||
e.preventDefault();
|
||||
var index = button.data("index");
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (onselect && _.isFunction(onselect)) {
|
||||
onselect(index, e);
|
||||
}
|
||||
modal.modal("hide");
|
||||
})
|
||||
});
|
||||
|
||||
return modal;
|
||||
|
||||
@@ -160,6 +160,10 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.onEventSettingsUpdated = function() {
|
||||
self.requestData();
|
||||
}
|
||||
|
||||
self.onStartup = function() {
|
||||
var connectionTab = $("#connection");
|
||||
connectionTab.on("show", function() {
|
||||
|
||||
@@ -339,7 +339,8 @@ $(function() {
|
||||
proceed: gettext("Yes"),
|
||||
onproceed: function() {
|
||||
OctoPrint.job.cancel();
|
||||
}
|
||||
},
|
||||
nofade: true
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
+2148
-1598
File diff suppressed because it is too large.
Load diff
+2
-4
@@ -1,4 +1,2 @@
|
||||
/*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="2.2.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=a&&a.toString();return!n.isArray(a)&&b-parseFloat(b)+1>=0},isPlainObject:function(a){var b;if("object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;if(a.constructor&&!k.call(a,"constructor")&&!k.call(a.constructor.prototype||{},"isPrototypeOf"))return!1;for(b in a);return void 0===b||k.call(a,b)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?i[j.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=d.createElement("script"),b.text=a,d.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(s(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):g.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:h.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,g=0,h=[];if(s(a))for(d=a.length;d>g;g++)e=b(a[g],g,c),null!=e&&h.push(e);else for(g in a)e=b(a[g],g,c),null!=e&&h.push(e);return f.apply([],h)},guid:1,proxy:function(a,b){var c,d,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(d=e.call(arguments,2),f=function(){return a.apply(b||this,d.concat(e.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:l}),"function"==typeof Symbol&&(n.fn[Symbol.iterator]=c[Symbol.iterator]),n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){i["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=!!a&&"length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+M+"))|)"+L+"*\\]",O=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+N+")*)|.*)\\)|)",P=new RegExp(L+"+","g"),Q=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),R=new ReLine truncated
|
||||
}catch(e){}O.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return O.hasData(a)||N.hasData(a)},data:function(a,b,c){return O.access(a,b,c)},removeData:function(a,b){O.remove(a,b)},_data:function(a,b,c){return N.access(a,b,c)},_removeData:function(a,b){N.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=O.get(f),1===f.nodeType&&!N.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),R(f,d,e[d])));N.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){O.set(this,a)}):K(this,function(b){var c,d;if(f&&void 0===b){if(c=O.get(f,a)||O.get(f,a.replace(Q,"-$&").toLowerCase()),void 0!==c)return c;if(d=n.camelCase(a),c=O.get(f,d),void 0!==c)return c;if(c=R(f,d,void 0),void 0!==c)return c}else d=n.camelCase(a),this.each(function(){var c=O.get(this,d);O.set(this,d,b),a.indexOf("-")>-1&&void 0!==c&&O.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){O.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=N.get(a,b),c&&(!d||n.isArray(c)?d=N.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return N.get(a,c)||N.access(a,c,{empty:n.Callbacks("once memory").add(function(){N.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=N.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),U=["Top","Right","Bottom","Left"],V=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)};function W(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return n.css(a,b,"")},i=h(),j=c&&c[3]||(n.cssNumber[b]?"":"px"),k=(n.cssNumber[b]||"px"!==j&&+i)&&T.exec(n.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,n.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var X=/^(?:checkbox|radio)$/i,Y=/<([\w:-]+)/,Z=/^$|\/(?:java|ecma)script/i,$={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};$.optgroup=$.option,$.tbody=$.tfoot=$.colgroup=$.caption=$.thead,$.th=$.td;function _(a,b){var c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function aa(a,b){for(var c=0,d=a.length;d>c;c++)N.set(a[c],"globalEval",!b||N.get(b[c],"globalEval"))}var ba=/<|&#?\w+;/;function ca(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],o=0,p=a.length;p>o;o++)if(f=a[o],f||0===f)if("object"===n.type(f))n.merge(m,f.nodeType?[f]:f);else if(ba.test(f)){g=g||l.appendChild(b.createElement("div")),h=(Y.exec(f)||["",""])[1].toLowerCase(),i=$[h]||$._default,g.innerHTML=i[1]+n.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;n.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",o=0;while(f=m[o++])if(d&&n.inArray(f,d)>-1)e&&e.push(f);else if(j=n.contains(f.ownerDocument,f),g=_(l.appendChild(f),"script"),j&&aa(g),c){k=0;while(f=g[k++])Z.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var da=/^key/,ea=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,fa=/^([^.]*)(?:\.(.+)|)/;function ga(){return!0}function ha(){return!1}function ia(){try{return d.activeElement}catch(a){}}function ja(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);forLine truncated
|
||||
void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=n.find.attr(a,"tabindex");return b?parseInt(b,10):cb.test(a.nodeName)||db.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),l.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var eb=/[\t\r\n\f]/g;function fb(a){return a.getAttribute&&a.getAttribute("class")||""}n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,fb(this)))});if("string"==typeof a&&a){b=a.match(G)||[];while(c=this[i++])if(e=fb(c),d=1===c.nodeType&&(" "+e+" ").replace(eb," ")){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=n.trim(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,fb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(G)||[];while(c=this[i++])if(e=fb(c),d=1===c.nodeType&&(" "+e+" ").replace(eb," ")){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=n.trim(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):n.isFunction(a)?this.each(function(c){n(this).toggleClass(a.call(this,c,fb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=n(this),f=a.match(G)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=fb(this),b&&N.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":N.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+fb(c)+" ").replace(eb," ").indexOf(b)>-1)return!0;return!1}});var gb=/\r/g,hb=/[\x20\t\r\n\f]+/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(gb,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a)).replace(hb," ")}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],(c.selected||i===e)&&(l.optDisabled?!c.disabled:null===c.getAttribute("disabled"))&&(!c.parentNode.disabled||!n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(n.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>-1:void 0}},l.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var ib=/^(?:focusinfocus|focusoutblur)$/;n.extend(n.event,{trigger:function(b,c,e,f){var g,h,i,j,l,m,o,p=[e||d],q=k.call(b,"type")?b.type:b,r=k.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!ib.test(q+n.event.triggered)&&(q.indexOf(".")>-1&&(r=q.split("."),q=r.shift(),r.sort()),l=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=r.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},f||!o.trigger||o.trigger.apply(e,c)!==!1)){if(!f&&!o.noBubble&&!n.isWindow(e)){for(j=o.delegateType||q,ib.test(j+q)||(h=h.parentNode);h;h=h.parentNode)p.push(h),i=h;i===(e.ownerDocument||d)&&p.push(i.defaultView||i.parentWindow||a)}g=0;while((h=p[g++])&&!b.isPropagationStopped())b.type=g>1?j:o.bindType||q,m=(N.get(h,"events")||{})[b.type]&&N.get(h,"handle"),m&&m.apply(h,c),m=l&&h[l],m&&m.apply&&L(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=q,f||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==Line truncated
|
||||
/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
|
||||
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:n.sort,splice:n.splice},w.extend=w.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||g(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)n=a[t],a!==(r=e[t])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},a[t]=w.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},w.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==c.call(e))&&(!(t=i(e))||"function"==typeof(n=f.call(t,"constructor")&&t.constructor)&&p.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var n,r=0;if(C(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(C(Object(e))?w.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:u.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;o<a;o++)(r=!t(e[o],o))!==s&&i.push(e[o]);return i},map:function(e,t,n){var r,i,o=0,s=[];if(C(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return a.apply([],s)},guid:1,support:h}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=n[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function C(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!g(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",I="\\["+M+"*("+R+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+R+"))|)"+M+"*\\]",W=":("+R+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+I+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),F=new RegExp("^"+M+"*,"+M+"*"),_=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)Line truncated
|
||||
@@ -73,7 +73,7 @@
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutTemperatureTargetSet" id="settings-serialTimeoutTemperatureTargetSet">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('When a target temperature is set')}}</span>
|
||||
<span class="help-inline">{{ _('When idle and a target temperature is set')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Temperature report interval to request from autoreport capable firmwares. A value of 0 disables autoreporting by the firmware and forces polling.') }}">
|
||||
@@ -90,9 +90,10 @@
|
||||
<label class="control-label" for="settings-serialTimeoutSdStatus">{{ _('SD status interval (polling)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutSdStatus" id="settings-serialTimeoutSdStatus">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutSdStatus" id="settings-serialTimeoutSdStatus">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('When printing from the printer\'s SD')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('SD status interval to request from autoreport capable firmwares. A value of 0 disables autoreporting by the firmware and forces polling.') }}">
|
||||
@@ -112,14 +113,14 @@
|
||||
<label class="control-label" for="settings-serialTimeoutCommunication">{{ _('Communication timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutCommunication" id="settings-serialTimeoutCommunication">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutCommunication" id="settings-serialTimeoutCommunication">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('<code>busy</code> protocol support not detected')}}</span>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutCommunicationBusy" id="settings-serialTimeoutCommunicationBusy">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutCommunicationBusy" id="settings-serialTimeoutCommunicationBusy">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('<code>busy</code> protocol support detected')}}</span>
|
||||
@@ -129,7 +130,7 @@
|
||||
<label class="control-label" for="settings-serialTimeoutConnection">{{ _('Connection timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutConnection" id="settings-serialTimeoutConnection">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutConnection" id="settings-serialTimeoutConnection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -138,7 +139,7 @@
|
||||
<label class="control-label" for="settings-serialTimeoutDetection">{{ _('Autodetection timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutDetection" id="settings-serialTimeoutDetection">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutDetection" id="settings-serialTimeoutDetection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -147,7 +148,7 @@
|
||||
<label class="control-label" for="settings-serialTimeoutPositionLogWait">{{ _('Position query timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutPositionLogWait" id="settings-serialTimeoutPositionLogWait">
|
||||
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutPositionLogWait" id="settings-serialTimeoutPositionLogWait">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1758,3 +1758,8 @@ class CaseInsensitiveSet(collections.Set):
|
||||
|
||||
def __len__(self):
|
||||
return len(self.data)
|
||||
|
||||
|
||||
# originally from https://stackoverflow.com/a/5967539
|
||||
def natural_key(text):
|
||||
return [ int(c) if c.isdigit() else c for c in re.split("(\d+)", text) ]
|
||||
+118
-34
@@ -11,6 +11,7 @@ import time
|
||||
import re
|
||||
import threading
|
||||
import contextlib
|
||||
import copy
|
||||
|
||||
try:
|
||||
import queue
|
||||
@@ -338,6 +339,15 @@ class MachineCom(object):
|
||||
STATE_TRANSFERING_FILE = 11
|
||||
STATE_CANCELLING = 12
|
||||
STATE_PAUSING = 13
|
||||
STATE_RESUMING = 14
|
||||
STATE_FINISHING = 15
|
||||
|
||||
# be sure to add anything here that signifies an operational state
|
||||
OPERATIONAL_STATES = (STATE_PRINTING, STATE_OPERATIONAL, STATE_PAUSED, STATE_CANCELLING, STATE_PAUSING,
|
||||
STATE_RESUMING, STATE_FINISHING, STATE_TRANSFERING_FILE)
|
||||
|
||||
# be sure to add anything here that signifies a printing state
|
||||
PRINTING_STATES = (STATE_PRINTING, STATE_CANCELLING, STATE_PAUSING, STATE_RESUMING, STATE_FINISHING)
|
||||
|
||||
CAPABILITY_AUTOREPORT_TEMP = "AUTOREPORT_TEMP"
|
||||
CAPABILITY_AUTOREPORT_SD_STATUS = "AUTOREPORT_SD_STATUS"
|
||||
@@ -489,6 +499,10 @@ class MachineCom(object):
|
||||
queuing=self._pluginManager.get_hooks("octoprint.comm.protocol.atcommand.queuing"),
|
||||
sending=self._pluginManager.get_hooks("octoprint.comm.protocol.atcommand.sending")
|
||||
)
|
||||
self._firmware_info_hooks = dict(
|
||||
info=self._pluginManager.get_hooks("octoprint.comm.protocol.firmware.info"),
|
||||
capabilities=self._pluginManager.get_hooks("octoprint.comm.protocol.firmware.capabilities")
|
||||
)
|
||||
|
||||
self._printer_action_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.action")
|
||||
self._gcodescript_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts")
|
||||
@@ -517,6 +531,9 @@ class MachineCom(object):
|
||||
self._record_pause_data = False
|
||||
self._record_cancel_data = False
|
||||
|
||||
self._suppress_scripts = set()
|
||||
self._suppress_scripts_mutex = threading.RLock()
|
||||
|
||||
self._pause_position_timer = None
|
||||
self._pause_mutex = threading.RLock()
|
||||
self._cancel_position_timer = None
|
||||
@@ -640,6 +657,10 @@ class MachineCom(object):
|
||||
return "Pausing"
|
||||
elif state == self.STATE_PAUSED:
|
||||
return "Paused"
|
||||
elif state == self.STATE_RESUMING:
|
||||
return "Resuming"
|
||||
elif state == self.STATE_FINISHING:
|
||||
return "Finishing"
|
||||
elif state == self.STATE_CLOSED:
|
||||
return "Offline"
|
||||
elif state == self.STATE_ERROR:
|
||||
@@ -660,11 +681,10 @@ class MachineCom(object):
|
||||
return self._state in (self.STATE_ERROR, self.STATE_CLOSED_WITH_ERROR)
|
||||
|
||||
def isOperational(self):
|
||||
return self._state in (self.STATE_OPERATIONAL, self.STATE_PRINTING, self.STATE_CANCELLING, self.STATE_PAUSING,
|
||||
self.STATE_PAUSED, self.STATE_TRANSFERING_FILE)
|
||||
return self._state in self.OPERATIONAL_STATES
|
||||
|
||||
def isPrinting(self):
|
||||
return self._state in (self.STATE_PRINTING, self.STATE_CANCELLING, self.STATE_PAUSING)
|
||||
return self._state in self.PRINTING_STATES
|
||||
|
||||
def isCancelling(self):
|
||||
return self._state == self.STATE_CANCELLING
|
||||
@@ -672,6 +692,12 @@ class MachineCom(object):
|
||||
def isPausing(self):
|
||||
return self._state == self.STATE_PAUSING
|
||||
|
||||
def isResuming(self):
|
||||
return self._state == self.STATE_RESUMING
|
||||
|
||||
def isFinishing(self):
|
||||
return self._state == self.STATE_FINISHING
|
||||
|
||||
def isSdPrinting(self):
|
||||
return self.isSdFileSelected() and self.isPrinting()
|
||||
|
||||
@@ -992,7 +1018,10 @@ class MachineCom(object):
|
||||
|
||||
self.sendCommand("M24", tags=tags | {"trigger:comm.start_print",})
|
||||
|
||||
self._sd_status_timer = RepeatedTimer(self._timeout_intervals.get("sdStatus", 1.0), self._poll_sd_status, run_first=True)
|
||||
interval = self._timeout_intervals.get("sdStatus", 1.0)
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
self._sd_status_timer = RepeatedTimer(interval, self._poll_sd_status, run_first=True)
|
||||
self._sd_status_timer.start()
|
||||
else:
|
||||
if pos is not None and isinstance(pos, int) and pos > 0:
|
||||
@@ -1185,7 +1214,15 @@ class MachineCom(object):
|
||||
self._log("Did not receive parseable position data from printer within {}s, continuing without it".format(timeout))
|
||||
self._pause_preparation_done()
|
||||
|
||||
def _pause_preparation_done(self, check_timer=True):
|
||||
def _pause_preparation_done(self, check_timer=True, suppress_script=None):
|
||||
if suppress_script is None:
|
||||
with self._suppress_scripts_mutex:
|
||||
suppress_script = "pause" in self._suppress_scripts
|
||||
try:
|
||||
self._suppress_scripts.remove("pause")
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
with self._pause_mutex:
|
||||
if self._pause_position_timer is not None:
|
||||
self._pause_position_timer.cancel()
|
||||
@@ -1193,14 +1230,14 @@ class MachineCom(object):
|
||||
elif check_timer:
|
||||
return
|
||||
|
||||
self._callback.on_comm_print_job_paused()
|
||||
self._callback.on_comm_print_job_paused(suppress_script=suppress_script)
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_PAUSED)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self._continue_sending()
|
||||
|
||||
def setPause(self, pause, tags=None):
|
||||
def setPause(self, pause, local_handling=True, tags=None):
|
||||
if self.isStreaming():
|
||||
return
|
||||
|
||||
@@ -1216,11 +1253,13 @@ class MachineCom(object):
|
||||
self._pauseWaitTimeLost = self._pauseWaitTimeLost + (time.time() - self._pauseWaitStartTime)
|
||||
self._pauseWaitStartTime = None
|
||||
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
self._callback.on_comm_print_job_resumed()
|
||||
self._changeState(self.STATE_RESUMING)
|
||||
self._callback.on_comm_print_job_resumed(suppress_script=not local_handling)
|
||||
self.sendCommand(SendQueueMarker(lambda: self._changeState(self.STATE_PRINTING)))
|
||||
|
||||
if self.isSdFileSelected():
|
||||
self.sendCommand("M24", tags=tags | {"trigger:comm.set_pause","trigger:resume"})
|
||||
if local_handling:
|
||||
self.sendCommand("M24", tags=tags | {"trigger:comm.set_pause","trigger:resume"})
|
||||
self.sendCommand("M27", tags=tags | {"trigger:comm.set_pause", "trigger:resume"})
|
||||
else:
|
||||
line, pos, lineno = self._getNext()
|
||||
@@ -1242,9 +1281,13 @@ class MachineCom(object):
|
||||
self._pauseWaitStartTime = time.time()
|
||||
|
||||
self._changeState(self.STATE_PAUSING)
|
||||
if self.isSdFileSelected():
|
||||
if self.isSdFileSelected() and local_handling:
|
||||
self.sendCommand("M25", tags=tags | {"trigger:comm.set_pause", "trigger:pause"}) # pause print
|
||||
|
||||
if not local_handling:
|
||||
with self._suppress_scripts_mutex:
|
||||
self._suppress_scripts.add("pause")
|
||||
|
||||
def _on_M400_sent():
|
||||
# we don't call on_print_job_paused on our callback here
|
||||
# because we do this only after our M114 has been answered
|
||||
@@ -1271,7 +1314,7 @@ class MachineCom(object):
|
||||
"trigger:record_position"})
|
||||
self._continue_sending()
|
||||
else:
|
||||
self._pause_preparation_done(check_timer=False)
|
||||
self._pause_preparation_done(check_timer=False, suppress_script=not local_handling)
|
||||
|
||||
def getSdFiles(self):
|
||||
return self._sdFiles
|
||||
@@ -1463,6 +1506,12 @@ class MachineCom(object):
|
||||
if self._dwelling_until and now > self._dwelling_until:
|
||||
self._dwelling_until = False
|
||||
|
||||
if self._resend_ok_timer and line and not line.startswith("ok"):
|
||||
# we got anything but an ok after a resend request - this means the ok after the resend request
|
||||
# was in fact missing and we now need to trigger the timer
|
||||
self._resend_ok_timer.cancel()
|
||||
self._resendSimulateOk()
|
||||
|
||||
##~~ busy protocol handling
|
||||
if line.startswith("echo:busy:") or line.startswith("busy:"):
|
||||
# reset the ok timeout, the regular comm timeout has already been reset
|
||||
@@ -1499,9 +1548,15 @@ class MachineCom(object):
|
||||
elif action_command == "pause":
|
||||
self._log("Pausing on request of the printer...")
|
||||
self.setPause(True)
|
||||
elif action_command == "paused":
|
||||
self._log("Printer signalled that it paused, switching state...")
|
||||
self.setPause(True, local_handling=False)
|
||||
elif action_command == "resume":
|
||||
self._log("Resuming on request of the printer...")
|
||||
self.setPause(False)
|
||||
elif action_command == "resumed":
|
||||
self._log("Printer signalled that it resumed, switching state...")
|
||||
self.setPause(False, local_handling=False)
|
||||
elif action_command == "disconnect":
|
||||
self._log("Disconnecting on request of the printer...")
|
||||
self._callback.on_comm_force_disconnect()
|
||||
@@ -1740,6 +1795,13 @@ class MachineCom(object):
|
||||
self._firmware_info = data
|
||||
self._firmware_name = firmware_name
|
||||
|
||||
# notify plugins
|
||||
for name, hook in self._firmware_info_hooks["info"].items():
|
||||
try:
|
||||
hook(self, firmware_name, copy.copy(data))
|
||||
except:
|
||||
self._logger.exception("Error processing firmware info hook {}:".format(name))
|
||||
|
||||
##~~ Firmware capability report triggered by M115
|
||||
elif lower_line.startswith("cap:"):
|
||||
parsed = parse_capability_line(lower_line)
|
||||
@@ -1755,6 +1817,13 @@ class MachineCom(object):
|
||||
self._logger.info("Firmware states that it supports sd status autoreporting")
|
||||
self._set_autoreport_sdstatus_interval()
|
||||
|
||||
# notify plugins
|
||||
for name, hook in self._firmware_info_hooks["capabilities"].items():
|
||||
try:
|
||||
hook(self, capability, enabled, copy.copy(self._firmware_capabilities))
|
||||
except:
|
||||
self._logger.exception("Error processing firmware capability hook {}:".format(name))
|
||||
|
||||
##~~ invalid extruder
|
||||
elif 'invalid extruder' in lower_line:
|
||||
tool = None
|
||||
@@ -1862,13 +1931,18 @@ class MachineCom(object):
|
||||
# printer is reporting file finished printing
|
||||
self._currentFile.done = True
|
||||
self._currentFile.pos = 0
|
||||
self._callback.on_comm_print_job_done()
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
|
||||
if self._sd_status_timer is not None:
|
||||
try:
|
||||
self._sd_status_timer.cancel()
|
||||
except:
|
||||
pass
|
||||
|
||||
self._changeState(self.STATE_FINISHING)
|
||||
self._callback.on_comm_print_job_done()
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
elif 'Done saving file' in line:
|
||||
if self._trigger_ok_for_m29:
|
||||
# workaround for most versions of Marlin out in the wild
|
||||
@@ -1975,16 +2049,17 @@ class MachineCom(object):
|
||||
|
||||
self._finish_heatup()
|
||||
|
||||
if not self._state in (self.STATE_PRINTING, self.STATE_OPERATIONAL, self.STATE_PAUSED, self.STATE_CANCELLING, self.STATE_PAUSING):
|
||||
if not self._state in self.OPERATIONAL_STATES:
|
||||
return
|
||||
|
||||
# process queues ongoing resend requests and queues if we are operational
|
||||
|
||||
if self._resendDelta is not None:
|
||||
self._resendNextCommand()
|
||||
else:
|
||||
self._resendActive = False
|
||||
self._continue_sending()
|
||||
with self._sendingLock: # prevent concurrency due to resend_ok_timers
|
||||
if self._resendDelta is not None:
|
||||
self._resendNextCommand()
|
||||
else:
|
||||
self._resendActive = False
|
||||
self._continue_sending()
|
||||
|
||||
return
|
||||
|
||||
@@ -2231,19 +2306,25 @@ class MachineCom(object):
|
||||
busy_default = 4.0
|
||||
target_default = 2.0
|
||||
|
||||
def get(key, default):
|
||||
interval = self._timeout_intervals.get(key, default)
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
return interval
|
||||
|
||||
if self.isBusy():
|
||||
return self._timeout_intervals.get("temperature", busy_default)
|
||||
return get("temperature", busy_default)
|
||||
|
||||
tools = self.last_temperature.tools
|
||||
for temp in [tools[k][1] for k in tools.keys()]:
|
||||
if temp > self._temperatureTargetSetThreshold:
|
||||
return self._timeout_intervals.get("temperatureTargetSet", target_default)
|
||||
return get("temperatureTargetSet", target_default)
|
||||
|
||||
bed = self.last_temperature.bed
|
||||
if bed and len(bed) > 0 and bed[1] > self._temperatureTargetSetThreshold:
|
||||
return self._timeout_intervals.get("temperatureTargetSet", target_default)
|
||||
return get("temperatureTargetSet", target_default)
|
||||
|
||||
return self._timeout_intervals.get("temperature", busy_default)
|
||||
return get("temperature", busy_default)
|
||||
|
||||
def _sendFromQueue(self):
|
||||
# We loop here to make sure that if we do NOT send the first command
|
||||
@@ -2500,6 +2581,7 @@ class MachineCom(object):
|
||||
if isinstance(self._currentFile, StreamingGcodeFileInformation):
|
||||
self._finishFileTransfer()
|
||||
else:
|
||||
self._changeState(self.STATE_FINISHING)
|
||||
self._callback.on_comm_print_job_done()
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
@@ -2622,13 +2704,15 @@ class MachineCom(object):
|
||||
if self._trigger_ok_after_resend == "always":
|
||||
self._handle_ok()
|
||||
elif self._trigger_ok_after_resend == "detect":
|
||||
def process():
|
||||
self._resend_ok_timer = None
|
||||
self._handle_ok()
|
||||
self._logger.info("Firmware didn't send an 'ok' with their resend request. That's a known bug with some firmware variants out there. Simulating an ok to continue...")
|
||||
self._resend_ok_timer = threading.Timer(self._timeout_intervals.get("resendOk", 1.0), process)
|
||||
self._resend_ok_timer = threading.Timer(self._timeout_intervals.get("resendOk", 1.0), self._resendSimulateOk)
|
||||
self._resend_ok_timer.start()
|
||||
|
||||
def _resendSimulateOk(self):
|
||||
self._resend_ok_timer = None
|
||||
self._handle_ok()
|
||||
self._logger.info("Firmware didn't send an 'ok' with their resend request. That's a known bug "
|
||||
"with some firmware variants out there. Simulating an ok to continue...")
|
||||
|
||||
def _resendSameCommand(self):
|
||||
return self._resendNextCommand(again=True)
|
||||
|
||||
@@ -3391,25 +3475,25 @@ class MachineComPrintCallback(object):
|
||||
def on_comm_progress(self):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_started(self):
|
||||
def on_comm_print_job_started(self, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_failed(self):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_done(self):
|
||||
def on_comm_print_job_done(self, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_cancelling(self, firmware_error=None):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_cancelled(self):
|
||||
def on_comm_print_job_cancelled(self, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_paused(self):
|
||||
def on_comm_print_job_paused(self, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_resumed(self):
|
||||
def on_comm_print_job_resumed(self, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_comm_z_change(self, newZ):
|
||||
|
||||
@@ -18,32 +18,7 @@ def get_octoprint_version_string():
|
||||
|
||||
def get_octoprint_version(base=False):
|
||||
octoprint_version_string = get_octoprint_version_string()
|
||||
|
||||
if "-" in octoprint_version_string:
|
||||
octoprint_version_string = octoprint_version_string[:octoprint_version_string.find("-")]
|
||||
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version_string)
|
||||
|
||||
# A leading v is common in github release tags and old setuptools doesn't remove it. While OctoPrint's
|
||||
# versions should never contain such a prefix, we'll make sure to have stuff behave the same
|
||||
# regardless of setuptools version anyhow.
|
||||
if octoprint_version and isinstance(octoprint_version, tuple) and octoprint_version[0].lower() == "*v":
|
||||
octoprint_version = octoprint_version[1:]
|
||||
|
||||
if base:
|
||||
if isinstance(octoprint_version, tuple):
|
||||
# old setuptools
|
||||
base_version = []
|
||||
for part in octoprint_version:
|
||||
if part.startswith("*"):
|
||||
break
|
||||
base_version.append(part)
|
||||
base_version.append("*final")
|
||||
octoprint_version = tuple(base_version)
|
||||
else:
|
||||
# new setuptools
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version.base_version)
|
||||
return octoprint_version
|
||||
return get_comparable_version(octoprint_version_string, base=base)
|
||||
|
||||
|
||||
def is_released_octoprint_version(version=None):
|
||||
@@ -140,3 +115,29 @@ def is_octoprint_compatible(*compatibility_entries, **kwargs):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_comparable_version(version_string, base=False):
|
||||
if "-" in version_string:
|
||||
version_string = version_string[:version_string.find("-")]
|
||||
|
||||
version = pkg_resources.parse_version(version_string)
|
||||
|
||||
# A leading v is common in github release tags and old setuptools doesn't remove it.
|
||||
if version and isinstance(version, tuple) and version[0].lower() == "*v":
|
||||
version = version[1:]
|
||||
|
||||
if base:
|
||||
if isinstance(version, tuple):
|
||||
# old setuptools
|
||||
base_version = []
|
||||
for part in version:
|
||||
if part.startswith("*"):
|
||||
break
|
||||
base_version.append(part)
|
||||
base_version.append("*final")
|
||||
version = tuple(base_version)
|
||||
else:
|
||||
# new setuptools
|
||||
version = pkg_resources.parse_version(version.base_version)
|
||||
return version
|
||||
Reference in new issue
Block a user