Metadata-Version: 2.5
Name: trytond_print3d
Version: 8.0.0.3
Summary: 3D printing management core module for Tryton
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: 3d printing,print job,printer,tryton
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: cryptography
Requires-Dist: trytond-stock<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

3D Printing Core
================

The ``print3d`` module is the Level 0 core of the print3d 3D printing
management group.  It holds the registry of the printers of the fleet, the
append-only history of their state, the log of the events and errors they
report and the print jobs that run on them, and it is the extension point
the vendor modules of the group build on.

Features
--------

- **Printer registry**: a printer names the machine (its name, its serial
  number and its vendor and model), the data a connector talks to it with
  (the host, the port, the protocol and whether the TLS certificate is
  verified), the connector that drives it, its current status, its own poll
  interval and its last poll, its location and its notes.
- **Connector framework**: a printer names its connector in a selection and
  not a foreign key, so the registry never depends on the modules that talk
  to the printers.  The base module ships no connector: a vendor module
  (``print3d_ultimaker``, ``print3d_prusa``, ``print3d_octoprint``) names
  its own in ``__setup__`` and registers it with
  ``print3d.connector.register_connector``.  The framework holds the
  interface a connector implements (``Connector``), the reading a connector
  hands back (``PrinterReading``) and the registry that binds the value a
  printer names to the class that drives it.  The core records the reading -
  the history, the current status and the events - so a connector reads its
  printer API and writes nothing of the core itself.
- **HTTP transport**: ``print3d.transport`` is what a connector of an HTTP
  printer API talks to the printer with: the timeout of a request, the
  retrying with an exponential backoff, the rate limit of a printer and the
  acceptance of the self signed certificate of a local printer API.  A
  secret never reaches a log: the transport logs the printer and the
  failure, never the request, a header or a body.
- **Credential store**: ``print3d.printer.credential`` holds the secrets a
  connector authenticates with, bound to their printer and named by an
  extendable kind.  A secret is encrypted at rest with the Fernet key of the
  deployment (``[print3d] secret_key``), is read as a mask and is closed by
  field access to everyone but the fleet administration; a deployment that
  names no key can store no secret.
- **Scheduled polling and pruning**: a scheduled action reads the fleet
  every minute and each printer's own ``poll_interval`` decides which
  printers are due; a printer that fails to answer is moved offline and
  logged without stopping the reading of the others.  A second action prunes
  the history at the retention of the deployment.
- **Printer components**: ``print3d.printer.component`` is the registry of
  the replaceable parts a printer carries - its print cores, its Material
  Station, its air manager, its camera - with the type of the part, the
  serial number, the position or slot it sits in and the dates it was
  installed and removed.  ``print3d.printer.component.move`` records every
  change of the mounting in an append-only history, so the installation
  history of a machine stays answerable after a part has been swapped.
- **Status history**: ``print3d.printer.status.snapshot`` records one
  reading of a printer - its state, its hotend and bed temperatures, the
  progress of the running print and the error it reported - so that the
  temperatures, the progress and the errors of a print stay answerable
  after the fact.  The core appends one reading per poll
  (``Printer.apply_reading``) and keeps the history at the retention of the
  deployment: what is older is aggregated to one reading per hour, or pruned
  away, by the prune action.
- **Event log**: ``print3d.print.event`` records one event a printer
  reports - the level it was raised with, the source and the message, with
  the raw payload the printer answered with kept beside the message.
- **Print jobs**: ``print3d.print.job`` is one thing a printer prints, with
  its lifecycle held in a state machine - ``draft``, ``queued``,
  ``printing`` and then ``done``, ``failed`` or ``cancelled`` - and the
  moments it started and ended.  The linkage to the spool and to the model
  library is added by a later milestone.

Dependencies
------------

- Tryton modules: ``ir``, ``res``, ``stock``.

``stock`` is required because a printer names the location it stands in,
and ``stock.location`` is where the fleet is placed.  The core deliberately
depends on no vendor module of the group: it is the registry the vendor
modules build on, so a vendor module depends on the core and never the
reverse.  The secrets of a credential are encrypted with ``cryptography``
(the Fernet construction), which is the one Python dependency of the module.

The settings of the group are read from the ``[print3d]`` section of the
configuration file of the server: ``secret_key`` (the Fernet key the secrets
are encrypted with), ``poll_interval``, ``request_timeout``,
``request_interval``, ``request_retries``, ``request_backoff``,
``verify_tls``, ``snapshot_retention`` and ``snapshot_aggregate``.  A value
the section does not name, or names and the setting can not read, is the
default of the setting.

Models
------

- ``print3d.printer``: a printer of the fleet.
- ``print3d.printer.status.snapshot``: one reading of the state of a
  printer.
- ``print3d.printer.component``: a replaceable component mounted in a
  printer.
- ``print3d.printer.component.move``: one change of the mounting of a
  component.
- ``print3d.print.event``: one event or error a printer reported.
- ``print3d.print.job``: one thing a printer prints, with its lifecycle.
- ``print3d.printer.credential``: one secret a connector authenticates
  against a printer with, encrypted at rest.

Security
--------

- ``group_print3d``: the read-only group.  It browses the printers, the
  history, the events and the print jobs but does not change them.
- ``group_print3d_admin``: full control over the module.
- The administration of the deployment (``res.group_admin``) is offered the
  screens as well.
- The ``value`` field of ``print3d.printer.credential`` is closed by field
  access to everyone by default and opened again to ``group_print3d_admin``
  alone, so a user who is not a fleet administrator may not read the field
  at all; even there it answers a mask and never the secret itself.

Documentation
-------------

The full documentation of the module is in ``doc/index.rst``, under
*Administration -> 3D Printing*.
