flashforge-python-api 1.6.0__py3-none-any.whl → 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flashforge/__init__.py +337 -256
- flashforge/_removed.py +65 -0
- flashforge/api/__init__.py +12 -18
- flashforge/api/constants/__init__.py +11 -11
- flashforge/api/constants/commands.py +18 -15
- flashforge/api/constants/endpoints.py +11 -11
- flashforge/api/misc/__init__.py +8 -8
- flashforge/api/network/__init__.py +11 -11
- flashforge/api/network/utils.py +71 -71
- flashforge/backends/__init__.py +80 -0
- flashforge/backends/connect.py +275 -0
- flashforge/backends/creator5_backend.py +191 -0
- flashforge/backends/dual_api_backend.py +170 -0
- flashforge/backends/dual_api_models.py +145 -0
- flashforge/backends/http_core.py +431 -0
- flashforge/backends/http_printer_backend.py +254 -0
- flashforge/backends/legacy_backend.py +436 -0
- flashforge/backends/printer_backend.py +217 -0
- flashforge/backends/types.py +125 -0
- flashforge/capabilities/__init__.py +98 -0
- flashforge/capabilities/models.py +67 -0
- flashforge/capabilities/palettes/__init__.py +28 -0
- flashforge/capabilities/palettes/ad5x_palette.py +70 -0
- flashforge/capabilities/palettes/creator5_palette.py +78 -0
- flashforge/capabilities/palettes/palette.py +54 -0
- flashforge/{api/controls/creator5_palette.py → capabilities/palettes/palette_snap.py} +226 -258
- flashforge/capabilities/printer_capabilities.py +145 -0
- flashforge/capabilities/registry.py +125 -0
- flashforge/capabilities/resolve_model.py +61 -0
- flashforge/discovery/__init__.py +39 -39
- flashforge/discovery/discovery.py +730 -763
- flashforge/exceptions.py +90 -51
- flashforge/models/__init__.py +52 -55
- flashforge/models/machine_info.py +540 -543
- flashforge/{api/controls/info.py → models/machine_info_parser.py} +35 -242
- flashforge/models/responses.py +119 -254
- flashforge/status/__init__.py +43 -0
- flashforge/status/printer_snapshot.py +396 -0
- flashforge/tcp/__init__.py +55 -54
- flashforge/tcp/a3_client.py +427 -427
- flashforge/tcp/a4_client.py +304 -304
- flashforge/tcp/ff_client.py +609 -590
- flashforge/tcp/gcode/__init__.py +15 -13
- flashforge/tcp/gcode/a3_gcode_controller.py +109 -109
- flashforge/tcp/gcode/gcode_controller.py +292 -308
- flashforge/tcp/gcode/gcodes.py +81 -99
- flashforge/tcp/gcode/legacy_gcode_controller.py +56 -0
- flashforge/tcp/parsers/__init__.py +27 -27
- flashforge/tcp/parsers/endstop_status.py +248 -248
- flashforge/tcp/parsers/location_info.py +83 -83
- flashforge/tcp/parsers/print_status.py +180 -180
- flashforge/tcp/parsers/printer_info.py +146 -146
- flashforge/tcp/parsers/temp_info.py +218 -218
- flashforge/tcp/parsers/thumbnail_info.py +274 -274
- flashforge/tcp/tcp_client.py +52 -12
- flashforge/threemf/__init__.py +40 -40
- flashforge/threemf/parser.py +560 -560
- flashforge/threemf/warnings.py +58 -58
- {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/METADATA +46 -47
- flashforge_python_api-3.0.0.dist-info/RECORD +69 -0
- {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/WHEEL +1 -1
- {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/licenses/LICENSE +21 -21
- flashforge/api/controls/__init__.py +0 -17
- flashforge/api/controls/control.py +0 -413
- flashforge/api/controls/files.py +0 -210
- flashforge/api/controls/job_control.py +0 -896
- flashforge/api/controls/temp_control.py +0 -309
- flashforge/client.py +0 -609
- flashforge_python_api-1.6.0.dist-info/RECORD +0 -52
- {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Static per-model facts and the rules that decide how far each fact can be trusted.
|
|
3
|
+
|
|
4
|
+
Trust rules (each field has exactly one source):
|
|
5
|
+
|
|
6
|
+
- ``model``: the model table is the truth. The printer's ``/product`` flags are ignored.
|
|
7
|
+
- ``printer``: the printer reports it. The model table does not say.
|
|
8
|
+
|
|
9
|
+
Live tests on 2026-11-14 showed that the Creator 5 series sends fixed ``/product``
|
|
10
|
+
values. Its chamber flag is set on the plain Creator 5, which has no chamber heater.
|
|
11
|
+
Both models ignore the filtration command. So chamber and filtration come from the
|
|
12
|
+
model table only.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from typing import Literal
|
|
19
|
+
|
|
20
|
+
from .models import BackendFamily, PrinterModelId
|
|
21
|
+
|
|
22
|
+
TrustSource = Literal["model", "printer"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class ModelSpec:
|
|
27
|
+
"""Static facts about one printer model."""
|
|
28
|
+
|
|
29
|
+
id: PrinterModelId
|
|
30
|
+
display_name: str
|
|
31
|
+
family: BackendFamily
|
|
32
|
+
#: The printer runs a TCP command server on port 8899.
|
|
33
|
+
tcp_command_channel: bool
|
|
34
|
+
#: Status comes from the HTTP ``/detail`` endpoint. When False, status comes over TCP.
|
|
35
|
+
http_status: bool
|
|
36
|
+
#: The field values were confirmed on real hardware. False for the Creator 5 series.
|
|
37
|
+
hardware_verified: bool
|
|
38
|
+
#: Number of tool heads.
|
|
39
|
+
tool_count: int = 1
|
|
40
|
+
#: Number of material-station slots. 0 when there is no station.
|
|
41
|
+
material_station_slots: int = 0
|
|
42
|
+
#: The station can load and unload filament (``ms_cmd``). AD5X only.
|
|
43
|
+
material_station_load_unload: bool = False
|
|
44
|
+
#: Heated chamber with API control. Creator 5 Pro only.
|
|
45
|
+
chamber_heater: bool = False
|
|
46
|
+
#: Air filtration with API control. Adventurer 5M Pro only.
|
|
47
|
+
filtration: bool = False
|
|
48
|
+
#: A real door sensor. Creator 5 Pro only. On other models the door flag is cosmetic.
|
|
49
|
+
door_sensor: bool = False
|
|
50
|
+
#: An air-quality (TVOC) sensor that the API reads (``/detail`` ``tvoc``). Adventurer 5M Pro
|
|
51
|
+
#: only. The base 5M and the Creator 5 series always report 0.
|
|
52
|
+
air_quality_sensor: bool = False
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#: Trust rule per capability field. A field listed as ``model`` never reads the printer flag.
|
|
56
|
+
FIELD_TRUST: dict[str, TrustSource] = {
|
|
57
|
+
"chamber_heater": "model",
|
|
58
|
+
"filtration": "model",
|
|
59
|
+
"door_sensor": "model",
|
|
60
|
+
"air_quality_sensor": "model",
|
|
61
|
+
"material_station": "model",
|
|
62
|
+
"led": "model",
|
|
63
|
+
"camera": "printer",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_M = PrinterModelId
|
|
67
|
+
_F = BackendFamily
|
|
68
|
+
|
|
69
|
+
#: The registry. One entry per model.
|
|
70
|
+
MODEL_REGISTRY: dict[PrinterModelId, ModelSpec] = {
|
|
71
|
+
_M.ADVENTURER_5M: ModelSpec(_M.ADVENTURER_5M, "Adventurer 5M", _F.DUAL_API, True, True, True),
|
|
72
|
+
_M.ADVENTURER_5M_PRO: ModelSpec(
|
|
73
|
+
_M.ADVENTURER_5M_PRO,
|
|
74
|
+
"Adventurer 5M Pro",
|
|
75
|
+
_F.DUAL_API,
|
|
76
|
+
True,
|
|
77
|
+
True,
|
|
78
|
+
True,
|
|
79
|
+
filtration=True,
|
|
80
|
+
air_quality_sensor=True,
|
|
81
|
+
),
|
|
82
|
+
_M.AD5X: ModelSpec(
|
|
83
|
+
_M.AD5X,
|
|
84
|
+
"AD5X",
|
|
85
|
+
_F.DUAL_API,
|
|
86
|
+
True,
|
|
87
|
+
True,
|
|
88
|
+
True,
|
|
89
|
+
material_station_slots=4,
|
|
90
|
+
material_station_load_unload=True,
|
|
91
|
+
),
|
|
92
|
+
_M.CREATOR_5: ModelSpec(
|
|
93
|
+
_M.CREATOR_5,
|
|
94
|
+
"Creator 5",
|
|
95
|
+
_F.HTTP_ONLY,
|
|
96
|
+
False,
|
|
97
|
+
True,
|
|
98
|
+
False,
|
|
99
|
+
tool_count=4,
|
|
100
|
+
material_station_slots=4,
|
|
101
|
+
),
|
|
102
|
+
_M.CREATOR_5_PRO: ModelSpec(
|
|
103
|
+
_M.CREATOR_5_PRO,
|
|
104
|
+
"Creator 5 Pro",
|
|
105
|
+
_F.HTTP_ONLY,
|
|
106
|
+
False,
|
|
107
|
+
True,
|
|
108
|
+
False,
|
|
109
|
+
tool_count=4,
|
|
110
|
+
material_station_slots=4,
|
|
111
|
+
chamber_heater=True,
|
|
112
|
+
door_sensor=True,
|
|
113
|
+
),
|
|
114
|
+
_M.ADVENTURER_4: ModelSpec(_M.ADVENTURER_4, "Adventurer 4", _F.LEGACY, True, False, False),
|
|
115
|
+
_M.ADVENTURER_3: ModelSpec(_M.ADVENTURER_3, "Adventurer 3", _F.LEGACY, True, False, False),
|
|
116
|
+
_M.GENERIC_LEGACY: ModelSpec(
|
|
117
|
+
_M.GENERIC_LEGACY, "FlashForge printer (legacy)", _F.LEGACY, True, False, False
|
|
118
|
+
),
|
|
119
|
+
_M.UNKNOWN: ModelSpec(_M.UNKNOWN, "Unknown printer", _F.UNKNOWN, False, False, False),
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def get_model_spec(model: PrinterModelId) -> ModelSpec:
|
|
124
|
+
"""Returns the spec for a model."""
|
|
125
|
+
return MODEL_REGISTRY[PrinterModelId(model)]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Resolves a printer model from the evidence the library has.
|
|
3
|
+
|
|
4
|
+
One function serves discovery, a first connection and a reconnect. Evidence is used in
|
|
5
|
+
this order:
|
|
6
|
+
|
|
7
|
+
1. PID (discovery USB product ID, or ``/detail`` ``pid``). Firmware-set; users cannot change it.
|
|
8
|
+
2. TCP ``M115`` machine type string (firmware-set).
|
|
9
|
+
3. The factory model name (``/detail`` ``model``), then the printer name as a last resort.
|
|
10
|
+
Users can rename a printer.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from .models import PrinterModelId, model_from_pid
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def resolve_model(
|
|
19
|
+
*,
|
|
20
|
+
pid: int | None = None,
|
|
21
|
+
machine_type: str | None = None,
|
|
22
|
+
name: str | None = None,
|
|
23
|
+
model_name: str | None = None,
|
|
24
|
+
has_material_station: bool = False,
|
|
25
|
+
) -> PrinterModelId:
|
|
26
|
+
"""Resolves the model. Returns ``UNKNOWN`` when nothing matches."""
|
|
27
|
+
by_pid = model_from_pid(pid)
|
|
28
|
+
if by_pid is not None:
|
|
29
|
+
return by_pid
|
|
30
|
+
if machine_type:
|
|
31
|
+
return model_from_machine_type(machine_type)
|
|
32
|
+
return _model_from_name(model_name or name or "", has_material_station)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def model_from_machine_type(machine_type: str) -> PrinterModelId:
|
|
36
|
+
"""Resolves a legacy model from a TCP ``M115`` machine type. Unknown types are generic."""
|
|
37
|
+
upper = machine_type.upper()
|
|
38
|
+
if "ADVENTURER 3" in upper or "ADVENTURER III" in upper:
|
|
39
|
+
return PrinterModelId.ADVENTURER_3
|
|
40
|
+
if "ADVENTURER 4" in upper:
|
|
41
|
+
return PrinterModelId.ADVENTURER_4
|
|
42
|
+
return PrinterModelId.GENERIC_LEGACY
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _model_from_name(name: str, has_material_station: bool) -> PrinterModelId:
|
|
46
|
+
upper = name.upper()
|
|
47
|
+
if "CREATOR 5 PRO" in upper:
|
|
48
|
+
return PrinterModelId.CREATOR_5_PRO
|
|
49
|
+
if "CREATOR 5" in upper:
|
|
50
|
+
return PrinterModelId.CREATOR_5
|
|
51
|
+
if has_material_station or upper == "AD5X" or "5X" in upper:
|
|
52
|
+
return PrinterModelId.AD5X
|
|
53
|
+
if "ADVENTURER 4" in upper or "ADVENTURER4" in upper or "AD4" in upper:
|
|
54
|
+
return PrinterModelId.ADVENTURER_4
|
|
55
|
+
if "ADVENTURER 3" in upper or "ADVENTURER3" in upper or "AD3" in upper:
|
|
56
|
+
return PrinterModelId.ADVENTURER_3
|
|
57
|
+
if "PRO" in upper:
|
|
58
|
+
return PrinterModelId.ADVENTURER_5M_PRO
|
|
59
|
+
if "5M" in upper:
|
|
60
|
+
return PrinterModelId.ADVENTURER_5M
|
|
61
|
+
return PrinterModelId.UNKNOWN
|
flashforge/discovery/__init__.py
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"""
|
|
2
|
-
FlashForge Python API - Discovery Package
|
|
3
|
-
|
|
4
|
-
UDP-based printer discovery for finding FlashForge printers on the local network.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from .discovery import (
|
|
8
|
-
DiscoveredPrinter,
|
|
9
|
-
DiscoveryError,
|
|
10
|
-
DiscoveryMonitor,
|
|
11
|
-
DiscoveryOptions,
|
|
12
|
-
DiscoveryProtocol,
|
|
13
|
-
DiscoveryTimeoutError,
|
|
14
|
-
FlashForgePrinter,
|
|
15
|
-
FlashForgePrinterDiscovery,
|
|
16
|
-
InvalidResponseError,
|
|
17
|
-
PrinterDiscovery,
|
|
18
|
-
|
|
19
|
-
PrinterStatus,
|
|
20
|
-
SocketCreationError,
|
|
21
|
-
main,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
__all__ = [
|
|
25
|
-
"PrinterDiscovery",
|
|
26
|
-
"DiscoveredPrinter",
|
|
27
|
-
"DiscoveryOptions",
|
|
28
|
-
"
|
|
29
|
-
"DiscoveryProtocol",
|
|
30
|
-
"PrinterStatus",
|
|
31
|
-
"DiscoveryMonitor",
|
|
32
|
-
"DiscoveryError",
|
|
33
|
-
"InvalidResponseError",
|
|
34
|
-
"SocketCreationError",
|
|
35
|
-
"DiscoveryTimeoutError",
|
|
36
|
-
"FlashForgePrinter",
|
|
37
|
-
"FlashForgePrinterDiscovery",
|
|
38
|
-
"main",
|
|
39
|
-
]
|
|
1
|
+
"""
|
|
2
|
+
FlashForge Python API - Discovery Package
|
|
3
|
+
|
|
4
|
+
UDP-based printer discovery for finding FlashForge printers on the local network.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .discovery import (
|
|
8
|
+
DiscoveredPrinter,
|
|
9
|
+
DiscoveryError,
|
|
10
|
+
DiscoveryMonitor,
|
|
11
|
+
DiscoveryOptions,
|
|
12
|
+
DiscoveryProtocol,
|
|
13
|
+
DiscoveryTimeoutError,
|
|
14
|
+
FlashForgePrinter,
|
|
15
|
+
FlashForgePrinterDiscovery,
|
|
16
|
+
InvalidResponseError,
|
|
17
|
+
PrinterDiscovery,
|
|
18
|
+
PrinterModelId,
|
|
19
|
+
PrinterStatus,
|
|
20
|
+
SocketCreationError,
|
|
21
|
+
main,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"PrinterDiscovery",
|
|
26
|
+
"DiscoveredPrinter",
|
|
27
|
+
"DiscoveryOptions",
|
|
28
|
+
"PrinterModelId",
|
|
29
|
+
"DiscoveryProtocol",
|
|
30
|
+
"PrinterStatus",
|
|
31
|
+
"DiscoveryMonitor",
|
|
32
|
+
"DiscoveryError",
|
|
33
|
+
"InvalidResponseError",
|
|
34
|
+
"SocketCreationError",
|
|
35
|
+
"DiscoveryTimeoutError",
|
|
36
|
+
"FlashForgePrinter",
|
|
37
|
+
"FlashForgePrinterDiscovery",
|
|
38
|
+
"main",
|
|
39
|
+
]
|