2012-12-25 10:55:00 +00:00
|
|
|
# coding=utf-8
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
This module defines the interface for communicating with a connected printer.
|
|
|
|
|
|
|
|
|
|
The communication is in fact divided in two components, the :class:`PrinterInterface` and a deeper lying
|
|
|
|
|
communcation layer. However, plugins should only ever need to use the :class:`PrinterInterface` as the
|
|
|
|
|
abstracted version of the actual printer communiciation.
|
|
|
|
|
|
|
|
|
|
.. autofunction:: get_connection_options
|
|
|
|
|
|
|
|
|
|
.. autoclass:: PrinterInterface
|
|
|
|
|
:members:
|
2015-03-06 00:42:49 +00:00
|
|
|
|
|
|
|
|
.. autoclass:: PrinterCallback
|
|
|
|
|
:members:
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
2012-12-28 19:37:40 +00:00
|
|
|
__author__ = "Gina Häußge <osd@foosel.net>"
|
2013-01-01 20:04:00 +00:00
|
|
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
2015-03-03 16:01:33 +00:00
|
|
|
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
2012-12-25 10:55:00 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
import re
|
2012-12-25 10:55:00 +00:00
|
|
|
|
2013-01-18 22:23:50 +00:00
|
|
|
import octoprint.util.comm as comm
|
|
|
|
|
from octoprint.settings import settings
|
2012-12-28 19:37:40 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_connection_options():
|
|
|
|
|
"""
|
|
|
|
|
Retrieves the available ports, baudrates, prefered port and baudrate for connecting to the printer.
|
2013-11-19 21:53:26 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Returned ``dict`` has the following structure::
|
2014-12-15 20:29:18 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
ports: <list of available serial ports>
|
|
|
|
|
baudrates: <list of available baudrates>
|
|
|
|
|
portPreference: <configured default serial port>
|
|
|
|
|
baudratePreference: <configured default baudrate>
|
|
|
|
|
autoconnect: <whether autoconnect upon server startup is enabled or not>
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
(dict): A dictionary holding the connection options in the structure specified above
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
|
|
|
|
return {
|
2012-12-31 12:18:54 +00:00
|
|
|
"ports": comm.serialList(),
|
|
|
|
|
"baudrates": comm.baudrateList(),
|
2013-02-16 19:28:09 +00:00
|
|
|
"portPreference": settings().get(["serial", "port"]),
|
2013-06-29 17:57:46 +00:00
|
|
|
"baudratePreference": settings().getInt(["serial", "baudrate"]),
|
|
|
|
|
"autoconnect": settings().getBoolean(["serial", "autoconnect"])
|
2012-12-28 19:37:40 +00:00
|
|
|
}
|
2012-12-25 10:55:00 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
|
|
|
|
|
class PrinterInterface(object):
|
|
|
|
|
"""
|
|
|
|
|
The :class:`PrinterInterface` represents the developer interface to the :class:`~octoprint.printer.standard.Printer`
|
|
|
|
|
instance.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
valid_axes = ("x", "y", "z", "e")
|
|
|
|
|
"""Valid axes identifiers."""
|
|
|
|
|
|
2015-03-06 15:54:41 +00:00
|
|
|
valid_tool_regex = re.compile("^(tool\d+)$")
|
2015-03-03 16:01:33 +00:00
|
|
|
"""Regex for valid tool identifiers."""
|
2012-12-25 10:55:00 +00:00
|
|
|
|
2015-03-06 15:54:41 +00:00
|
|
|
valid_heater_regex = re.compile("^(tool\d+|bed)$")
|
|
|
|
|
"""Regex for valid heater identifiers."""
|
|
|
|
|
|
2014-11-28 08:32:44 +00:00
|
|
|
def connect(self, port=None, baudrate=None, profile=None):
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
Connects to the printer, using the specified serial ``port``, ``baudrate`` and printer ``profile``. If a
|
|
|
|
|
connection is already established, that connection will be closed prior to connecting anew with the provided
|
|
|
|
|
parameters.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
port (str): Name of the serial port to connect to. If not provided, an auto detection will be attempted.
|
2015-03-03 16:01:33 +00:00
|
|
|
baudrate (int): Baudrate to connect with. If not provided, an auto detection will be attempted.
|
2015-03-06 15:54:41 +00:00
|
|
|
profile (str): Name of the printer profile to use for this connection. If not provided, the default
|
2015-03-03 16:01:33 +00:00
|
|
|
will be retrieved from the :class:`PrinterProfileManager`.
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
pass
|
2012-12-25 10:55:00 +00:00
|
|
|
|
|
|
|
|
def disconnect(self):
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
Disconnects from the printer. Does nothing if no connection is currently established.
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
raise NotImplementedError()
|
2012-12-25 10:55:00 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_transport(self):
|
2015-02-17 20:53:45 +00:00
|
|
|
"""
|
|
|
|
|
Returns the communication layer's transport object, if a connection is currently established.
|
|
|
|
|
|
|
|
|
|
Note that this doesn't have to necessarily be a :class:`serial.Serial` instance, it might also be something
|
|
|
|
|
different, so take care to do instance checks before attempting to access any properties or methods.
|
|
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Returns:
|
|
|
|
|
object: The communication layer's transport object
|
2015-02-17 20:53:45 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
raise NotImplementedError()
|
2015-02-17 20:53:45 +00:00
|
|
|
|
2015-04-27 16:13:39 +00:00
|
|
|
def fake_ack(self):
|
|
|
|
|
"""
|
|
|
|
|
Fakes an acknowledgement for the communication layer. If the communication between OctoPrint and the printer
|
|
|
|
|
gets stuck due to lost "ok" responses from the server due to communication issues, this can be used to get
|
|
|
|
|
things going again.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def commands(self, commands):
|
|
|
|
|
"""
|
|
|
|
|
Sends the provided ``commands`` to the printer.
|
2015-02-17 20:53:45 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
commands (str, list): The commands to send. Might be a single command provided just as a string or a list
|
2015-03-03 16:01:33 +00:00
|
|
|
of multiple commands to send in order.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2015-02-17 20:53:45 +00:00
|
|
|
|
2015-03-06 15:04:43 +00:00
|
|
|
def script(self, name, context=None):
|
|
|
|
|
"""
|
|
|
|
|
Sends the GCODE script ``name`` to the printer.
|
|
|
|
|
|
|
|
|
|
The script will be run through the template engine, the rendering context can be extended by providing a
|
|
|
|
|
``context`` with additional template variables to use.
|
|
|
|
|
|
|
|
|
|
If the script is unknown, an :class:`UnknownScriptException` will be raised.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
name (str): The name of the GCODE script to render.
|
2015-03-06 15:04:43 +00:00
|
|
|
context (dict): An optional context of additional template variables to provide to the renderer.
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
UnknownScriptException: There is no GCODE script with name ``name``
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def jog(self, axis, amount):
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
Jogs the specified printer ``axis`` by the specified ``amount`` in mm.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
axis (str): The axis to jog, will be converted to lower case, one of "x", "y", "z" or "e"
|
2015-03-03 16:01:33 +00:00
|
|
|
amount (int, float): The amount by which to jog in mm
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
raise NotImplementedError()
|
2012-12-26 14:03:34 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def home(self, axes):
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
Homes the specified printer ``axes``.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
axes (str, list): The axis or axes to home, each of which must converted to lower case must match one of
|
2015-03-03 16:01:33 +00:00
|
|
|
"x", "y", "z" and "e"
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
raise NotImplementedError()
|
2013-09-08 15:49:01 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def extrude(self, amount):
|
|
|
|
|
"""
|
|
|
|
|
Extrude ``amount`` milimeters of material from the tool.
|
2012-12-25 10:55:00 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
|
|
|
|
amount (int, float): The amount of material to extrude in mm
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2014-01-01 01:39:35 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def change_tool(self, tool):
|
|
|
|
|
"""
|
|
|
|
|
Switch the currently active ``tool`` (for which extrude commands will apply).
|
2014-01-01 01:39:35 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
tool (str): The tool to switch to, matching the regex "tool[0-9]+" (e.g. "tool0", "tool1", ...)
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def set_temperature(self, heater, value):
|
|
|
|
|
"""
|
|
|
|
|
Sets the target temperature on the specified ``heater`` to the given ``value`` in celsius.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
heater (str): The heater for which to set the target temperature. Either "bed" for setting the bed
|
2015-03-03 16:01:33 +00:00
|
|
|
temperature or something matching the regular expression "tool[0-9]+" (e.g. "tool0", "tool1", ...) for
|
|
|
|
|
the hotends of the printer
|
|
|
|
|
value (int, float): The temperature in celsius to set the target temperature to.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def set_temperature_offset(self, offsets=None):
|
|
|
|
|
"""
|
|
|
|
|
Sets the temperature ``offsets`` to apply to target temperatures red from a GCODE file while printing.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
offsets (dict): A dictionary specifying the offsets to apply. Keys must match the format for the ``heater``
|
|
|
|
|
parameter to :func:`set_temperature`, so "bed" for the offset for the bed target temperature and
|
|
|
|
|
"tool[0-9]+" for the offsets to the hotend target temperatures.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def feed_rate(self, factor):
|
|
|
|
|
"""
|
|
|
|
|
Sets the ``factor`` for the printer's feed rate.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
factor (int, float): The factor for the feed rate to send to the firmware. Percentage expressed as either an
|
|
|
|
|
int between 0 and 100 or a float between 0 and 1.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def flow_rate(self, factor):
|
|
|
|
|
"""
|
|
|
|
|
Sets the ``factor`` for the printer's flow rate.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
factor (int, float): The factor for the flow rate to send to the firmware. Percentage expressed as either an
|
|
|
|
|
int between 0 and 100 or a float between 0 and 1.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def select_file(self, path, sd, printAfterSelect=False):
|
|
|
|
|
"""
|
|
|
|
|
Selects the specified ``path`` for printing, specifying if the file is to be found on the ``sd`` or not.
|
|
|
|
|
Optionally can also directly start the print after selecting the file.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
path (str): The path to select for printing. Either an absolute path (local file) or a
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2014-01-01 01:39:35 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def unselect_file(self):
|
|
|
|
|
"""
|
|
|
|
|
Unselects and currently selected file.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-09-09 00:35:24 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def start_print(self):
|
|
|
|
|
"""
|
|
|
|
|
Starts printing the currently selected file. If no file is currently selected, does nothing.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-01-06 15:51:04 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def toggle_pause_print(self):
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
Pauses the current print job if it is currently running or resumes it if it is currently paused.
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
raise NotImplementedError()
|
2013-01-06 15:51:04 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def cancel_print(self):
|
|
|
|
|
"""
|
|
|
|
|
Cancels the current print job.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-01-06 15:51:04 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_state_string(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
2015-03-06 15:54:41 +00:00
|
|
|
(str) A human readable string corresponding to the current communication state.
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-26 16:53:43 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_current_data(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(dict) The current state data.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_current_job(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(dict) The data of the current job.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_current_temperatures(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(dict) The current temperatures.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_temperature_history(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(list) The temperature history.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def get_current_connection(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(tuple) The current connection information as a 4-tuple ``(connection_string, port, baudrate, printer_profile)``.
|
|
|
|
|
If the printer is currently not connected, the tuple will be ``("Closed", None, None, None)``.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-31 20:41:53 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def is_closed_or_error(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(boolean) Whether the printer is currently disconnected and/or in an error state.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def is_operational(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(boolean) Whether the printer is currently connected and available.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-31 20:41:53 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def is_printing(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(boolean) Whether the printer is currently printing.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-11-19 21:53:26 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def is_paused(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(boolean) Whether the printer is currently paused.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def is_error(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(boolean) Whether the printer is currently in an error state.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def is_ready(self):
|
|
|
|
|
"""
|
|
|
|
|
Returns:
|
|
|
|
|
(boolean) Whether the printer is currently operational and ready for new print jobs (not printing).
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
def register_callback(self, callback):
|
|
|
|
|
"""
|
|
|
|
|
Registers a :class:`PrinterCallback` with the instance.
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
|
|
|
|
callback (PrinterCallback): The callback object to register.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-06-21 18:50:57 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def unregister_callback(self, callback):
|
|
|
|
|
"""
|
|
|
|
|
Unregisters a :class:`PrinterCallback` from the instance.
|
2014-12-19 23:31:46 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
|
|
|
|
callback (PrinterCallback): The callback object to unregister.
|
|
|
|
|
"""
|
|
|
|
|
raise NotImplementedError()
|
2013-05-20 17:18:03 +00:00
|
|
|
|
|
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
class PrinterCallback(object):
|
|
|
|
|
def on_printer_add_log(self, data):
|
|
|
|
|
"""
|
|
|
|
|
Called when the :class:`PrinterInterface` receives a new communication log entry from the communication layer.
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
data (str): The received log line.
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
pass
|
2013-09-23 16:40:46 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def on_printer_add_message(self, data):
|
|
|
|
|
"""
|
|
|
|
|
Called when the :class:`PrinterInterface` receives a new message from the communication layer.
|
2013-09-23 16:40:46 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
data (str): The received message.
|
2015-03-03 16:01:33 +00:00
|
|
|
"""
|
|
|
|
|
pass
|
2013-12-21 13:46:20 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def on_printer_add_temperature(self, data):
|
|
|
|
|
"""
|
|
|
|
|
Called when the :class:`PrinterInterface` receives a new temperature data set from the communication layer.
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
``data`` is a ``dict`` of the following structure::
|
2013-05-20 17:18:03 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
tool0:
|
|
|
|
|
actual: <temperature of the first hotend, in degC>
|
|
|
|
|
target: <target temperature of the first hotend, in degC>
|
|
|
|
|
...
|
|
|
|
|
bed:
|
|
|
|
|
actual: <temperature of the bed, in degC>
|
|
|
|
|
target: <target temperature of the bed, in degC>
|
2013-05-26 16:53:43 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
Arguments:
|
|
|
|
|
data (dict): A dict of all current temperatures in the format as specified above
|
|
|
|
|
"""
|
|
|
|
|
pass
|
2013-05-26 16:53:43 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def on_printer_received_registered_message(self, name, output):
|
2013-09-23 16:40:46 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
Called when the :class:`PrinterInterface` received a registered message, e.g. from a feedback command.
|
|
|
|
|
|
|
|
|
|
Arguments:
|
2015-03-06 15:54:41 +00:00
|
|
|
name (str): Name of the registered message (e.g. the feedback command)
|
|
|
|
|
output (str): Output for the registered message
|
2013-09-23 16:40:46 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
pass
|
2013-05-26 16:53:43 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def on_printer_send_initial_data(self, data):
|
|
|
|
|
"""
|
|
|
|
|
Called when registering as a callback with the :class:`PrinterInterface` to receive the initial data (state,
|
|
|
|
|
log and temperature history etc) from the printer.
|
|
|
|
|
|
|
|
|
|
``data`` is a ``dict`` of the following structure::
|
|
|
|
|
|
|
|
|
|
temps:
|
|
|
|
|
- time: <timestamp of the temperature data point>
|
|
|
|
|
tool0:
|
|
|
|
|
actual: <temperature of the first hotend, in degC>
|
|
|
|
|
target: <target temperature of the first hotend, in degC>
|
|
|
|
|
...
|
|
|
|
|
bed:
|
|
|
|
|
actual: <temperature of the bed, in degC>
|
|
|
|
|
target: <target temperature of the bed, in degC>
|
|
|
|
|
- ...
|
|
|
|
|
logs: <list of current communication log lines>
|
|
|
|
|
messages: <list of current messages from the firmware>
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
data (dict): The initial data in the format as specified above.
|
|
|
|
|
"""
|
|
|
|
|
pass
|
2013-01-06 15:51:04 +00:00
|
|
|
|
2015-03-03 16:01:33 +00:00
|
|
|
def on_printer_send_current_data(self, data):
|
|
|
|
|
"""
|
|
|
|
|
Called when the internal state of the :class:`PrinterInterface` changes, due to changes in the printer state,
|
|
|
|
|
temperatures, log lines, job progress etc. Updates via this method are guaranteed to be throttled to a maximum
|
|
|
|
|
of 2 calles per second.
|
|
|
|
|
|
|
|
|
|
``data`` is a ``dict`` of the following structure::
|
|
|
|
|
|
|
|
|
|
state:
|
|
|
|
|
text: <current state string>
|
|
|
|
|
flags:
|
|
|
|
|
operational: <whether the printer is currently connected and responding>
|
|
|
|
|
printing: <whether the printer is currently printing>
|
|
|
|
|
closedOrError: <whether the printer is currently disconnected and/or in an error state>
|
|
|
|
|
error: <whether the printer is currently in an error state>
|
|
|
|
|
paused: <whether the printer is currently paused>
|
|
|
|
|
ready: <whether the printer is operational and ready for jobs>
|
|
|
|
|
sdReady: <whether an SD card is present>
|
|
|
|
|
job:
|
|
|
|
|
file:
|
|
|
|
|
name: <name of the file>,
|
|
|
|
|
size: <size of the file in bytes>,
|
|
|
|
|
origin: <origin of the file, "local" or "sdcard">,
|
|
|
|
|
date: <last modification date of the file>
|
|
|
|
|
estimatedPrintTime: <estimated print time of the file in seconds>
|
|
|
|
|
lastPrintTime: <last print time of the file in seconds>
|
|
|
|
|
filament:
|
|
|
|
|
length: <estimated length of filament needed for this file, in mm>
|
|
|
|
|
volume: <estimated volume of filament needed for this file, in ccm>
|
|
|
|
|
progress:
|
|
|
|
|
completion: <progress of the print job in percent (0-100)>
|
|
|
|
|
filepos: <current position in the file in bytes>
|
|
|
|
|
printTime: <current time elapsed for printing, in seconds>
|
|
|
|
|
printTimeLeft: <estimated time left to finish printing, in seconds>
|
|
|
|
|
currentZ: <current position of the z axis, in mm>
|
|
|
|
|
offsets: <current configured temperature offsets, keys are "bed" or "tool[0-9]+", values the offset in degC>
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
data (dict): The current data in the format as specified above.
|
2012-12-28 19:37:40 +00:00
|
|
|
"""
|
2015-03-03 16:01:33 +00:00
|
|
|
pass
|
|
|
|
|
|
2015-03-06 15:04:43 +00:00
|
|
|
class UnknownScript(BaseException):
|
|
|
|
|
def __init__(self, name, *args, **kwargs):
|
|
|
|
|
self.name = name
|