flashforge-python-api 1.6.0__py3-none-any.whl → 3.1.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 +137 -56
- 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 +150 -77
- 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.1.0.dist-info}/METADATA +46 -47
- flashforge_python_api-3.1.0.dist-info/RECORD +69 -0
- {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.1.0.dist-info}/WHEEL +1 -1
- {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.1.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.1.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
FlashForge Python API - Temperature Control Module
|
|
3
|
-
|
|
4
|
-
Sets and cancels extruder/bed/chamber temperatures. The 5M / 5M Pro / AD5X use
|
|
5
|
-
direct TCP G-code/M-code commands; HTTP-only printers (Creator 5 / 5 Pro, no TCP
|
|
6
|
-
channel) use the HTTP ``temperatureCtl_cmd`` instead.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import logging
|
|
10
|
-
from typing import TYPE_CHECKING
|
|
11
|
-
|
|
12
|
-
from ..constants.commands import Commands
|
|
13
|
-
|
|
14
|
-
if TYPE_CHECKING:
|
|
15
|
-
from ...client import FlashForgeClient
|
|
16
|
-
from ...tcp.ff_client import FlashForgeClient as TcpClient
|
|
17
|
-
|
|
18
|
-
logger = logging.getLogger(__name__)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Sentinel value for `temperatureCtl_cmd` meaning "leave this heater unchanged"
|
|
22
|
-
# (partial update). Sending a real 0 / -100 would turn the heater off.
|
|
23
|
-
TEMP_NO_CHANGE = -200
|
|
24
|
-
# `temperatureCtl_cmd` value that turns a SCALAR heater (platform / chamber /
|
|
25
|
-
# rightNozzle) off.
|
|
26
|
-
TEMP_OFF = -100
|
|
27
|
-
# Value that turns a tool/nozzle OFF inside the `nozzles` array. Unlike the scalar
|
|
28
|
-
# heater fields (which accept TEMP_OFF = -100), the Creator 5 firmware's
|
|
29
|
-
# per-nozzle parser only treats a literal 0 as "off" — it ignores -100 in the
|
|
30
|
-
# `nozzles` array and the tool keeps heating (observed on live hardware;
|
|
31
|
-
# this is the v1.6.1 nozzle-off bugfix).
|
|
32
|
-
NOZZLE_OFF = 0
|
|
33
|
-
# Number of tool/nozzle entries the Creator 5 firmware requires in the
|
|
34
|
-
# `nozzles` array. The firmware ignores the array unless its length is exactly
|
|
35
|
-
# this (verified in the firmware).
|
|
36
|
-
NOZZLE_COUNT = 4
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class TempControl:
|
|
40
|
-
"""
|
|
41
|
-
Provides methods for controlling the temperatures of various printer components,
|
|
42
|
-
including extruders and the print bed.
|
|
43
|
-
|
|
44
|
-
Dual-API printers (5M / 5M Pro / AD5X) use TCP G-code commands; HTTP-only
|
|
45
|
-
printers (Creator 5 / 5 Pro) route through the HTTP ``temperatureCtl_cmd``.
|
|
46
|
-
"""
|
|
47
|
-
|
|
48
|
-
def __init__(self, client: "FlashForgeClient"):
|
|
49
|
-
"""
|
|
50
|
-
Creates an instance of the TempControl class.
|
|
51
|
-
|
|
52
|
-
Args:
|
|
53
|
-
client: The FlashForgeClient instance used for communication with the printer.
|
|
54
|
-
"""
|
|
55
|
-
self.client = client
|
|
56
|
-
self._tcp_client: TcpClient | None = None
|
|
57
|
-
|
|
58
|
-
@property
|
|
59
|
-
def tcp_client(self) -> "TcpClient":
|
|
60
|
-
"""Get the TCP client instance."""
|
|
61
|
-
if self._tcp_client is None:
|
|
62
|
-
self._tcp_client = self.client.tcp_client
|
|
63
|
-
return self._tcp_client
|
|
64
|
-
|
|
65
|
-
async def _send_http_temp_command(
|
|
66
|
-
self,
|
|
67
|
-
right_nozzle: int | None = None,
|
|
68
|
-
left_nozzle: int | None = None,
|
|
69
|
-
platform: int | None = None,
|
|
70
|
-
chamber: int | None = None,
|
|
71
|
-
nozzles: list[int] | None = None,
|
|
72
|
-
) -> bool:
|
|
73
|
-
"""
|
|
74
|
-
Sends a ``temperatureCtl_cmd`` over HTTP with the given setpoints.
|
|
75
|
-
Unspecified heaters are left unchanged via the :data:`TEMP_NO_CHANGE`
|
|
76
|
-
sentinel.
|
|
77
|
-
|
|
78
|
-
The ``nozzles`` array is Creator 5-only (its 4-nozzle tool changer). The
|
|
79
|
-
confirmed C5 payload ALWAYS carries a 4-entry array, even on a bed- or
|
|
80
|
-
chamber-only command, so always include it on the C5 — defaulting
|
|
81
|
-
unspecified tools to :data:`TEMP_NO_CHANGE` so a bed/chamber adjustment
|
|
82
|
-
leaves the tools untouched.
|
|
83
|
-
|
|
84
|
-
Returns:
|
|
85
|
-
True if the command is acknowledged, False otherwise.
|
|
86
|
-
"""
|
|
87
|
-
payload: dict[str, int | list[int]] = {
|
|
88
|
-
"rightNozzle": right_nozzle if right_nozzle is not None else TEMP_NO_CHANGE,
|
|
89
|
-
"leftNozzle": left_nozzle if left_nozzle is not None else TEMP_NO_CHANGE,
|
|
90
|
-
"platform": platform if platform is not None else TEMP_NO_CHANGE,
|
|
91
|
-
"chamber": chamber if chamber is not None else TEMP_NO_CHANGE,
|
|
92
|
-
}
|
|
93
|
-
# The `nozzles` array is Creator 5-only. The confirmed C5 payload always
|
|
94
|
-
# carries a 4-entry array, even on a bed- or chamber-only command, so
|
|
95
|
-
# always include it on the C5 — defaulting unspecified tools to
|
|
96
|
-
# TEMP_NO_CHANGE so a bed/chamber adjustment leaves the tools untouched.
|
|
97
|
-
if nozzles is not None:
|
|
98
|
-
payload["nozzles"] = nozzles
|
|
99
|
-
elif self.client.is_creator5:
|
|
100
|
-
payload["nozzles"] = [TEMP_NO_CHANGE] * NOZZLE_COUNT
|
|
101
|
-
return await self.client.control.send_control_command(Commands.TEMP_CONTROL_CMD, payload)
|
|
102
|
-
|
|
103
|
-
def _build_nozzle_array(self, tool_index: int, value: int) -> list[int] | None:
|
|
104
|
-
"""
|
|
105
|
-
Builds a :data:`NOZZLE_COUNT`-length ``nozzles`` array of
|
|
106
|
-
:data:`TEMP_NO_CHANGE` placeholders with a single tool set to ``value``.
|
|
107
|
-
|
|
108
|
-
Returns:
|
|
109
|
-
The array, or None if ``tool_index`` is out of range.
|
|
110
|
-
"""
|
|
111
|
-
if not isinstance(tool_index, int) or tool_index < 0 or tool_index >= NOZZLE_COUNT:
|
|
112
|
-
logger.warning(
|
|
113
|
-
"TempControl: tool_index %s out of range (0-%s).", tool_index, NOZZLE_COUNT - 1
|
|
114
|
-
)
|
|
115
|
-
return None
|
|
116
|
-
nozzles = [TEMP_NO_CHANGE] * NOZZLE_COUNT
|
|
117
|
-
nozzles[tool_index] = value
|
|
118
|
-
return nozzles
|
|
119
|
-
|
|
120
|
-
async def set_tool_temp(self, tool_index: int, temp: int) -> bool:
|
|
121
|
-
"""
|
|
122
|
-
Sets the target temperature for a single tool/nozzle on a Creator 5 series
|
|
123
|
-
tool-changer, leaving the other tools unchanged. Sent as a ``nozzles``
|
|
124
|
-
array (Creator 5 / 5 Pro, HTTP-only).
|
|
125
|
-
|
|
126
|
-
Args:
|
|
127
|
-
tool_index: Zero-based tool index (0-3 for T0-T3).
|
|
128
|
-
temp: Target temperature in Celsius.
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
True if the command is acknowledged, False otherwise.
|
|
132
|
-
"""
|
|
133
|
-
nozzles = self._build_nozzle_array(tool_index, temp)
|
|
134
|
-
if nozzles is None:
|
|
135
|
-
return False
|
|
136
|
-
return await self._send_http_temp_command(nozzles=nozzles)
|
|
137
|
-
|
|
138
|
-
async def set_tool_temps(self, temps: list[int]) -> bool:
|
|
139
|
-
"""
|
|
140
|
-
Sets the target temperatures for all tools/nozzles on a Creator 5 series
|
|
141
|
-
tool-changer in one command. Use :data:`TEMP_NO_CHANGE` (-200) to leave a
|
|
142
|
-
tool unchanged or :data:`NOZZLE_OFF` (0) to turn one off (the firmware
|
|
143
|
-
ignores the -100 sentinel inside the ``nozzles`` array). Must contain
|
|
144
|
-
exactly :data:`NOZZLE_COUNT` entries.
|
|
145
|
-
|
|
146
|
-
Args:
|
|
147
|
-
temps: Per-tool target temperatures, ordered T0..T3.
|
|
148
|
-
|
|
149
|
-
Returns:
|
|
150
|
-
True if the command is acknowledged, False otherwise.
|
|
151
|
-
"""
|
|
152
|
-
if len(temps) != NOZZLE_COUNT:
|
|
153
|
-
logger.warning("set_tool_temps: expected %s temps, got %s.", NOZZLE_COUNT, len(temps))
|
|
154
|
-
return False
|
|
155
|
-
return await self._send_http_temp_command(nozzles=list(temps))
|
|
156
|
-
|
|
157
|
-
async def cancel_tool_temp(self, tool_index: int) -> bool:
|
|
158
|
-
"""
|
|
159
|
-
Cancels heating for a single tool/nozzle on a Creator 5 series tool-changer
|
|
160
|
-
(sets its target to 0 via :data:`NOZZLE_OFF`), leaving the other tools
|
|
161
|
-
unchanged.
|
|
162
|
-
|
|
163
|
-
Args:
|
|
164
|
-
tool_index: Zero-based tool index (0-3 for T0-T3).
|
|
165
|
-
|
|
166
|
-
Returns:
|
|
167
|
-
True if the command is acknowledged, False otherwise.
|
|
168
|
-
"""
|
|
169
|
-
nozzles = self._build_nozzle_array(tool_index, NOZZLE_OFF)
|
|
170
|
-
if nozzles is None:
|
|
171
|
-
return False
|
|
172
|
-
return await self._send_http_temp_command(nozzles=nozzles)
|
|
173
|
-
|
|
174
|
-
async def set_extruder_temp(self, temperature: int, wait_for: bool = False) -> bool:
|
|
175
|
-
"""
|
|
176
|
-
Sets the target temperature for the printer's extruder.
|
|
177
|
-
|
|
178
|
-
On HTTP-only printers this routes to ``temperatureCtl_cmd``: the Creator 5
|
|
179
|
-
drives its tools only via the ``nozzles`` array (targeting T0), while a
|
|
180
|
-
forced-http_only AD5X / 5M keeps the ``rightNozzle`` scalar.
|
|
181
|
-
|
|
182
|
-
Args:
|
|
183
|
-
temperature: The target temperature in Celsius.
|
|
184
|
-
wait_for: Whether to wait for the heating operation to complete (TCP only).
|
|
185
|
-
|
|
186
|
-
Returns:
|
|
187
|
-
True if the command is successful, False otherwise.
|
|
188
|
-
"""
|
|
189
|
-
if self.client.http_only:
|
|
190
|
-
# Creator 5 tools are driven ONLY via the `nozzles` array — the
|
|
191
|
-
# firmware's temperature-control handler never reads
|
|
192
|
-
# rightNozzle/leftNozzle. Target the primary tool (T0): the active
|
|
193
|
-
# tool isn't reliably known over HTTP, so callers that need a
|
|
194
|
-
# specific tool should use set_tool_temp(index, temp).
|
|
195
|
-
if self.client.is_creator5:
|
|
196
|
-
nozzles = self._build_nozzle_array(0, temperature)
|
|
197
|
-
if nozzles is None:
|
|
198
|
-
return False
|
|
199
|
-
return await self._send_http_temp_command(nozzles=nozzles)
|
|
200
|
-
# Single-tool AD5X / 5M only reachable here if forced into http_only
|
|
201
|
-
# mode; they keep the rightNozzle field (unchanged).
|
|
202
|
-
return await self._send_http_temp_command(right_nozzle=temperature)
|
|
203
|
-
return await self.tcp_client.set_extruder_temp(temperature, wait_for)
|
|
204
|
-
|
|
205
|
-
async def set_bed_temp(self, temperature: int, wait_for: bool = False) -> bool:
|
|
206
|
-
"""
|
|
207
|
-
Sets the target temperature for the printer's print bed.
|
|
208
|
-
|
|
209
|
-
Args:
|
|
210
|
-
temperature: The target bed temperature in Celsius.
|
|
211
|
-
wait_for: Whether to wait for the heating operation to complete (TCP only).
|
|
212
|
-
|
|
213
|
-
Returns:
|
|
214
|
-
True if the command is successful, False otherwise.
|
|
215
|
-
"""
|
|
216
|
-
if self.client.http_only:
|
|
217
|
-
return await self._send_http_temp_command(platform=temperature)
|
|
218
|
-
return await self.tcp_client.set_bed_temp(temperature, wait_for)
|
|
219
|
-
|
|
220
|
-
async def cancel_extruder_temp(self) -> bool:
|
|
221
|
-
"""
|
|
222
|
-
Cancels any ongoing extruder heating and sets its target temperature to 0.
|
|
223
|
-
|
|
224
|
-
Returns:
|
|
225
|
-
True if the command is successful, False otherwise.
|
|
226
|
-
"""
|
|
227
|
-
if self.client.http_only:
|
|
228
|
-
# See set_extruder_temp: Creator 5 tools are driven only via
|
|
229
|
-
# `nozzles`. Turn the primary tool (T0) off (target 0, not the -100
|
|
230
|
-
# sentinel the nozzles array ignores) while leaving the other tools
|
|
231
|
-
# unchanged.
|
|
232
|
-
if self.client.is_creator5:
|
|
233
|
-
nozzles = self._build_nozzle_array(0, NOZZLE_OFF)
|
|
234
|
-
if nozzles is None:
|
|
235
|
-
return False
|
|
236
|
-
return await self._send_http_temp_command(nozzles=nozzles)
|
|
237
|
-
# Single-tool AD5X / 5M (forced http_only) keep rightNozzle (unchanged).
|
|
238
|
-
return await self._send_http_temp_command(right_nozzle=TEMP_OFF)
|
|
239
|
-
return await self.tcp_client.cancel_extruder_temp()
|
|
240
|
-
|
|
241
|
-
async def cancel_bed_temp(self) -> bool:
|
|
242
|
-
"""
|
|
243
|
-
Cancels any ongoing print bed heating and sets its target temperature to 0.
|
|
244
|
-
|
|
245
|
-
Returns:
|
|
246
|
-
True if the command is successful, False otherwise.
|
|
247
|
-
"""
|
|
248
|
-
if self.client.http_only:
|
|
249
|
-
return await self._send_http_temp_command(platform=TEMP_OFF)
|
|
250
|
-
return await self.tcp_client.cancel_bed_temp()
|
|
251
|
-
|
|
252
|
-
async def set_chamber_temp(self, temp: int) -> bool:
|
|
253
|
-
"""
|
|
254
|
-
Sets the target temperature for the printer's heated chamber. Only the
|
|
255
|
-
Creator 5 series has a chamber heater, and those printers are HTTP-only,
|
|
256
|
-
so this always goes over the HTTP ``temperatureCtl_cmd``. The firmware
|
|
257
|
-
caps the chamber at 80°C.
|
|
258
|
-
|
|
259
|
-
Args:
|
|
260
|
-
temp: The target temperature in Celsius.
|
|
261
|
-
|
|
262
|
-
Returns:
|
|
263
|
-
True if the command is acknowledged, False otherwise.
|
|
264
|
-
"""
|
|
265
|
-
if not self.client.is_creator5 and not self.client.is_creator5_pro:
|
|
266
|
-
logger.warning(
|
|
267
|
-
"set_chamber_temp: the chamber heater is only available on the Creator 5 series."
|
|
268
|
-
)
|
|
269
|
-
return False
|
|
270
|
-
return await self._send_http_temp_command(chamber=temp)
|
|
271
|
-
|
|
272
|
-
async def cancel_chamber_temp(self) -> bool:
|
|
273
|
-
"""
|
|
274
|
-
Cancels any ongoing chamber heating and sets its target temperature to 0.
|
|
275
|
-
|
|
276
|
-
Returns:
|
|
277
|
-
True if the command is acknowledged, False otherwise.
|
|
278
|
-
"""
|
|
279
|
-
if not self.client.is_creator5 and not self.client.is_creator5_pro:
|
|
280
|
-
logger.warning(
|
|
281
|
-
"cancel_chamber_temp: the chamber heater is only available on the Creator 5 series."
|
|
282
|
-
)
|
|
283
|
-
return False
|
|
284
|
-
return await self._send_http_temp_command(chamber=TEMP_OFF)
|
|
285
|
-
|
|
286
|
-
async def wait_for_part_cool(
|
|
287
|
-
self, target_temp: float = 50.0, timeout_seconds: int = 1800
|
|
288
|
-
) -> bool:
|
|
289
|
-
"""
|
|
290
|
-
Waits for printer components to cool down to a safe temperature.
|
|
291
|
-
|
|
292
|
-
Relies on TCP G-code polling and is therefore unavailable on HTTP-only
|
|
293
|
-
printers (Creator 5 / 5 Pro); callers should poll ``info.get()`` instead.
|
|
294
|
-
|
|
295
|
-
Args:
|
|
296
|
-
target_temp: The target temperature to wait for (default: 50°C).
|
|
297
|
-
timeout_seconds: Maximum time to wait in seconds (default: 30 minutes).
|
|
298
|
-
|
|
299
|
-
Returns:
|
|
300
|
-
True if components cooled to target temperature, False if timeout, error,
|
|
301
|
-
or HTTP-only (no TCP polling channel).
|
|
302
|
-
"""
|
|
303
|
-
if self.client.http_only:
|
|
304
|
-
logger.warning(
|
|
305
|
-
"wait_for_part_cool is unavailable over an HTTP-only connection; "
|
|
306
|
-
"poll info.get() instead."
|
|
307
|
-
)
|
|
308
|
-
return False
|
|
309
|
-
return await self.tcp_client.wait_for_part_cool(target_temp, timeout_seconds)
|