You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add wrapper function for machine registry
* Decorate entrypoint functions
* Docstrings
* Fix for boolean setting
* Add playwright tests
* Use proper entrypoints
* Ensure settings are fetched correctly
* Prevent recursion of machine registry decorator
* Fix machine status display
* Enhanced warning msg
* Add simple machine sample printer
* Adds playwright tests for machine UI
* re-throw exception
* Define 'machine' plugin mixin class
* Adjust machine discovery
* Use plugin mixins for registering machine types and drivers
* Adjust unit test
* Remove plugin static files when deactivating
* Force machine reload when plugin registry changes
* Add plugins specific to testing framework
* Add test for plugin loading sequence
* Add session caching
- Significantly reduce DB hits
* Enhanced unit testing and test plugins
* Refactor unit tests
* Further unit test fixes
* Adjust instance rendering
* Display table of available drivers
* Cleanup
* ADjust unit test
* Tweak unit test
* Add docs on new mixin type
* Tweak machine overview docs
* Tweak playwright tests
* Additional unit test
* Add unit test for calling machine func
* Enhanced playwright tests
* Account for database not being ready
Copy file name to clipboardExpand all lines: docs/docs/plugins/machines/label_printer.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,18 @@
1
-
## Label printer
1
+
---
2
+
title: Label Printer Machines
3
+
---
4
+
5
+
## Label Printer
2
6
3
7
Label printer machines can directly print labels for various items in InvenTree. They replace standard [`LabelPrintingMixin`](../mixins/label.md) plugins that are used to connect to physical printers. Using machines rather than a standard `LabelPrintingMixin` plugin has the advantage that machines can be created multiple times using different settings but the same driver. That way multiple label printers of the same brand can be connected.
4
8
5
-
### Writing your own printing driver
9
+
### Writing A Custom Driver
10
+
11
+
To implement a custom label printer driver, you need to write a plugin which implements the [MachineDriverMixin](../mixins/machine.md) and returns a list of label printer drivers in the `get_machine_drivers` method.
6
12
7
13
Take a look at the most basic required code for a driver in this [example](./overview.md#example-driver). Next either implement the [`print_label`](#machine.machine_types.LabelPrinterBaseDriver.print_label) or [`print_labels`](#machine.machine_types.LabelPrinterBaseDriver.print_labels) function.
8
14
9
-
### Label printer status
15
+
### Label Printer Status
10
16
11
17
There are a couple of predefined status codes for label printers. By default the `UNKNOWN` status code is set for each machine, but they can be changed at any time by the driver. For more info about status code see [Machine status codes](./overview.md#machine-status).
Copy file name to clipboardExpand all lines: docs/docs/plugins/machines/overview.md
+26-14Lines changed: 26 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ InvenTree has a builtin machine registry. There are different machine types avai
13
13
14
14
The machine registry is the main component which gets initialized on server start and manages all configured machines.
15
15
16
-
#### Initialization process
16
+
#### Initialization Process
17
17
18
18
The machine registry initialization process can be divided into three stages:
19
19
@@ -24,24 +24,27 @@ The machine registry initialization process can be divided into three stages:
24
24
2. The driver.init_driver function is called for each used driver
25
25
3. The machine.initialize function is called for each machine, which calls the driver.init_machine function for each machine, then the machine.initialized state is set to true
26
26
27
-
#### Production setup (with a worker)
27
+
#### Production Setup
28
+
29
+
!!! warning "Cache Required"
30
+
A [shared cache](../../start/processes.md#cache-server) is required to run the machine registry in production setup with workers.
28
31
29
32
If a worker is connected, there exist multiple instances of the machine registry (one in each worker thread and one in the main thread) due to the nature of how python handles state in different processes. Therefore the machine instances and drivers are instantiated multiple times (The `__init__` method is called multiple times). But the init functions and update hooks (e.g. `init_machine`) are only called once from the main process.
30
33
31
34
The registry, driver and machine state (e.g. machine status codes, errors, ...) is stored in the cache. Therefore a shared redis cache is needed. (The local in-memory cache which is used by default is not capable to cache across multiple processes)
32
35
33
36
34
-
### Machine types
37
+
### Machine Types
35
38
36
39
Each machine type can provide a different type of connection functionality between inventree and a physical machine. These machine types are already built into InvenTree.
37
40
38
-
#### Built-in types
41
+
#### Builtin Types
39
42
40
43
| Name | Description |
41
44
| --- | --- |
42
45
|[Label printer](./label_printer.md)| Directly print labels for various items. |
43
46
44
-
#### Example machine type
47
+
#### Example Machine Type
45
48
46
49
If you want to create your own machine type, please also take a look at the already existing machine types in `machines/machine_types/*.py`. The following example creates a machine type called `abc`.
47
50
@@ -109,24 +112,33 @@ The machine type class gets instantiated for each machine on server startup and
109
112
110
113
Drivers provide the connection layer between physical machines and inventree. There can be multiple drivers defined for the same machine type. Drivers are provided by plugins that are enabled and extend the corresponding base driver for the particular machine type. Each machine type already provides a base driver that needs to be inherited.
111
114
112
-
#### Example driver
115
+
#### Example Driver
113
116
114
117
A basic driver only needs to specify the basic attributes like `SLUG`, `NAME`, `DESCRIPTION`. The others are given by the used base driver, so take a look at [Machine types](#machine-types). The following example will create an driver called `abc` for the `xyz` machine type. The class will be discovered if it is provided by an **installed & activated** plugin just like this:
115
118
116
-
```py
119
+
```python
120
+
from plugin.mixins import MachineDriverMixin
117
121
from plugin import InvenTreePlugin
118
122
from plugin.machine.machine_types import ABCBaseDriver
119
123
120
-
classMyXyzAbcDriverPlugin(InvenTreePlugin):
121
-
NAME="XyzAbcDriver"
122
-
SLUG="xyz-driver"
123
-
TITLE="Xyz Abc Driver"
124
-
# ...
125
124
126
125
classXYZDriver(ABCBaseDriver):
127
126
SLUG='my-xyz-driver'
128
127
NAME='My XYZ driver'
129
128
DESCRIPTION='This is an awesome XYZ driver for a ABC machine'
"""Return a list of machine drivers for this plugin."""
139
+
return [XYZDriver]
140
+
141
+
130
142
```
131
143
132
144
#### Driver API
@@ -161,7 +173,7 @@ class MyXYZDriver(ABCBaseDriver):
161
173
162
174
Settings can even marked as `'required': True` which prevents the machine from starting if the setting is not defined.
163
175
164
-
### Machine status
176
+
### Machine Status
165
177
166
178
Machine status can be used to report the machine status to the users. They can be set by the driver for each machine, but get lost on a server restart.
167
179
@@ -186,7 +198,7 @@ class XYZMachineType(BaseMachineType):
186
198
187
199
And to set a status code for a machine by the driver.
Copy file name to clipboardExpand all lines: docs/docs/plugins/mixins/barcode.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Barcode Mixin
3
3
---
4
4
5
-
## Barcode Plugins
5
+
## BarcodeMixin
6
6
7
7
InvenTree supports decoding of arbitrary barcode data and generation of internal barcode formats via a **Barcode Plugin** interface. Barcode data POSTed to the `/api/barcode/` endpoint will be supplied to all loaded barcode plugins, and the first plugin to successfully interpret the barcode data will return a response to the client.
The `MachineDriverMixin` class is used to implement custom machine drivers (or machine types) in InvenTree.
8
+
9
+
InvenTree supports integration with [external machines](../machines/overview.md), through the use of plugin-supplied device drivers.
10
+
11
+
### get_machine_drivers
12
+
13
+
To register custom machine driver(s), the `get_machine_drivers` method must be implemented. This method should return a list of machine driver classes that the plugin supports.
The default implementation returns an empty list, meaning no custom machine drivers are registered.
26
+
27
+
### get_machine_types
28
+
29
+
To register custom machine type(s), the `get_machine_types` method must be implemented. This method should return a list of machine type classes that the plugin supports.
Copy file name to clipboardExpand all lines: docs/docs/settings/error_codes.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,11 @@ A plugin is not allowed to override a *final method* from the `InvenTreePlugin`
75
75
76
76
This is a security measure to prevent plugins from changing the core functionality of InvenTree. The code of the plugin must be changed to not override functions that are marked as *final*.
77
77
78
+
#### INVE-E12
79
+
**Plugin returned invalid machine type - Backend**
80
+
81
+
An error occurred when discovering or initializing a machine type from a plugin. This likely indicates a faulty or incompatible plugin.
82
+
78
83
### INVE-W (InvenTree Warning)
79
84
Warnings - These are non-critical errors which should be addressed when possible.
0 commit comments