flashforge-python-api 1.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 +188 -0
- flashforge/api/__init__.py +17 -0
- flashforge/api/constants/__init__.py +10 -0
- flashforge/api/constants/commands.py +10 -0
- flashforge/api/constants/endpoints.py +11 -0
- flashforge/api/controls/__init__.py +16 -0
- flashforge/api/controls/control.py +357 -0
- flashforge/api/controls/files.py +171 -0
- flashforge/api/controls/info.py +292 -0
- flashforge/api/controls/job_control.py +561 -0
- flashforge/api/controls/temp_control.py +89 -0
- flashforge/api/filament/__init__.py +7 -0
- flashforge/api/filament/filament.py +39 -0
- flashforge/api/misc/__init__.py +8 -0
- flashforge/api/misc/scientific_notation.py +28 -0
- flashforge/api/misc/temperature.py +42 -0
- flashforge/api/network/__init__.py +10 -0
- flashforge/api/network/fnet_code.py +15 -0
- flashforge/api/network/utils.py +55 -0
- flashforge/client.py +381 -0
- flashforge/discovery/__init__.py +12 -0
- flashforge/discovery/discovery.py +388 -0
- flashforge/models/__init__.py +50 -0
- flashforge/models/machine_info.py +247 -0
- flashforge/models/responses.py +123 -0
- flashforge/tcp/__init__.py +41 -0
- flashforge/tcp/ff_client.py +587 -0
- flashforge/tcp/gcode/__init__.py +11 -0
- flashforge/tcp/gcode/gcode_controller.py +296 -0
- flashforge/tcp/gcode/gcodes.py +93 -0
- flashforge/tcp/parsers/__init__.py +27 -0
- flashforge/tcp/parsers/endstop_status.py +273 -0
- flashforge/tcp/parsers/location_info.py +68 -0
- flashforge/tcp/parsers/print_status.py +182 -0
- flashforge/tcp/parsers/printer_info.py +154 -0
- flashforge/tcp/parsers/temp_info.py +217 -0
- flashforge/tcp/parsers/thumbnail_info.py +242 -0
- flashforge/tcp/tcp_client.py +448 -0
- flashforge_python_api-1.0.0.dist-info/METADATA +123 -0
- flashforge_python_api-1.0.0.dist-info/RECORD +43 -0
- flashforge_python_api-1.0.0.dist-info/WHEEL +4 -0
- flashforge_python_api-1.0.0.dist-info/entry_points.txt +2 -0
- flashforge_python_api-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FlashForge Python API - Response Models
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional, Union
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .machine_info import FFPrinterDetail, FFGcodeFileEntry
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class GenericResponse(BaseModel):
|
|
12
|
+
"""Represents a generic response from the printer's API."""
|
|
13
|
+
code: int
|
|
14
|
+
message: str = ""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DetailResponse(GenericResponse):
|
|
18
|
+
"""Represents the structure of the response from the printer's detail endpoint."""
|
|
19
|
+
detail: FFPrinterDetail
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Product(BaseModel):
|
|
23
|
+
"""
|
|
24
|
+
Defines the structure of the `product` object nested within a `ProductResponse`.
|
|
25
|
+
|
|
26
|
+
This contains various control state flags reported by the printer,
|
|
27
|
+
indicating the status or availability of certain features like temperature controls,
|
|
28
|
+
fan controls, and light controls. A state of 0 often means off/unavailable,
|
|
29
|
+
while other numbers (typically 1) mean on/available or a specific mode.
|
|
30
|
+
|
|
31
|
+
Field names match the actual camelCase format returned by the printer.
|
|
32
|
+
"""
|
|
33
|
+
chamberTempCtrlState: int
|
|
34
|
+
externalFanCtrlState: int
|
|
35
|
+
internalFanCtrlState: int
|
|
36
|
+
lightCtrlState: int
|
|
37
|
+
nozzleTempCtrlState: int
|
|
38
|
+
platformTempCtrlState: int
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ProductResponse(GenericResponse):
|
|
42
|
+
"""
|
|
43
|
+
Represents the expected structure of the response from the "product command"
|
|
44
|
+
sent to the printer (typically to the `/product` endpoint).
|
|
45
|
+
|
|
46
|
+
This response includes general status information (via `GenericResponse`)
|
|
47
|
+
and a nested `product` object containing specific control states.
|
|
48
|
+
"""
|
|
49
|
+
product: Product
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class FilamentArgs(BaseModel):
|
|
53
|
+
"""Represents the arguments for controlling the printer's filtration system."""
|
|
54
|
+
internal: str
|
|
55
|
+
external: str
|
|
56
|
+
|
|
57
|
+
def __init__(self, internal_on: bool, external_on: bool):
|
|
58
|
+
super().__init__(
|
|
59
|
+
internal="open" if internal_on else "close",
|
|
60
|
+
external="open" if external_on else "close"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class AD5XMaterialMapping(BaseModel):
|
|
65
|
+
"""Represents a material mapping for AD5X multi-color printing. Maps a tool (extruder) to a specific material station slot."""
|
|
66
|
+
tool_id: int = Field(ge=0, le=3, description="Tool ID (0-based: 0, 1, 2, 3)")
|
|
67
|
+
slot_id: int = Field(ge=1, le=4, description="Slot ID (1-based: 1, 2, 3, 4)")
|
|
68
|
+
material_name: str = Field(description="Name of the material (e.g., 'PLA', 'SILK')")
|
|
69
|
+
tool_material_color: str = Field(description="Hex color code for the tool material (e.g., '#FFFFFF')")
|
|
70
|
+
slot_material_color: str = Field(description="Hex color code for the slot material (e.g., '#46328E')")
|
|
71
|
+
|
|
72
|
+
class Config:
|
|
73
|
+
populate_by_name = True
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class AD5XLocalJobParams(BaseModel):
|
|
77
|
+
"""Parameters for starting an AD5X local job with material mappings. Used for multi-color prints that utilize the material station."""
|
|
78
|
+
file_name: str = Field(description="Name of the file on the printer to start")
|
|
79
|
+
leveling_before_print: bool = Field(description="Whether to perform bed leveling before printing")
|
|
80
|
+
material_mappings: list[AD5XMaterialMapping] = Field(description="Array of material mappings (1-4 items)")
|
|
81
|
+
|
|
82
|
+
class Config:
|
|
83
|
+
populate_by_name = True
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class AD5XSingleColorJobParams(BaseModel):
|
|
87
|
+
"""Parameters for starting an AD5X single-color local job. Used for single-color prints that do not require the material station."""
|
|
88
|
+
file_name: str = Field(description="Name of the file on the printer to start")
|
|
89
|
+
leveling_before_print: bool = Field(description="Whether to perform bed leveling before printing")
|
|
90
|
+
|
|
91
|
+
class Config:
|
|
92
|
+
populate_by_name = True
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class AD5XUploadParams(BaseModel):
|
|
96
|
+
"""Parameters for uploading a file to AD5X printer with material station support. Extends basic upload functionality with AD5X-specific features."""
|
|
97
|
+
file_path: str = Field(description="Local file path to upload")
|
|
98
|
+
start_print: bool = Field(description="Whether to start printing immediately after upload")
|
|
99
|
+
leveling_before_print: bool = Field(description="Whether to perform bed leveling before printing")
|
|
100
|
+
flow_calibration: bool = Field(description="Whether to enable flow calibration")
|
|
101
|
+
first_layer_inspection: bool = Field(description="Whether to enable first layer inspection")
|
|
102
|
+
time_lapse_video: bool = Field(description="Whether to enable time lapse video recording")
|
|
103
|
+
material_mappings: list[AD5XMaterialMapping] = Field(description="Array of material mappings for the material station (1-4 items)")
|
|
104
|
+
|
|
105
|
+
class Config:
|
|
106
|
+
populate_by_name = True
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class GCodeListResponse(GenericResponse):
|
|
110
|
+
"""Represents the response structure for a G-code file list request."""
|
|
111
|
+
gcode_list: Optional[Union[list[str], list[FFGcodeFileEntry]]] = Field(default=None, alias="gcodeList")
|
|
112
|
+
gcode_list_detail: Optional[list[FFGcodeFileEntry]] = Field(default=None, alias="gcodeListDetail")
|
|
113
|
+
|
|
114
|
+
class Config:
|
|
115
|
+
populate_by_name = True
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class ThumbnailResponse(GenericResponse):
|
|
119
|
+
"""Represents the response structure for a G-code thumbnail request."""
|
|
120
|
+
image_data: str = Field(alias="imageData", description="The thumbnail image data encoded as a base64 string")
|
|
121
|
+
|
|
122
|
+
class Config:
|
|
123
|
+
populate_by_name = True
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TCP communication layer for FlashForge 3D printers.
|
|
3
|
+
|
|
4
|
+
This module provides low-level TCP socket communication and high-level G-code interfaces
|
|
5
|
+
for controlling FlashForge printers via their TCP API.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .ff_client import FlashForgeClient
|
|
9
|
+
from .gcode import GCodeController, GCodes
|
|
10
|
+
from .parsers import (
|
|
11
|
+
Endstop,
|
|
12
|
+
EndstopStatus,
|
|
13
|
+
LocationInfo,
|
|
14
|
+
MachineStatus,
|
|
15
|
+
MoveMode,
|
|
16
|
+
PrinterInfo,
|
|
17
|
+
PrintStatus,
|
|
18
|
+
Status,
|
|
19
|
+
TempData,
|
|
20
|
+
TempInfo,
|
|
21
|
+
ThumbnailInfo,
|
|
22
|
+
)
|
|
23
|
+
from .tcp_client import FlashForgeTcpClient
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
'FlashForgeTcpClient',
|
|
27
|
+
'FlashForgeClient',
|
|
28
|
+
'GCodes',
|
|
29
|
+
'GCodeController',
|
|
30
|
+
'PrinterInfo',
|
|
31
|
+
'TempInfo',
|
|
32
|
+
'TempData',
|
|
33
|
+
'LocationInfo',
|
|
34
|
+
'EndstopStatus',
|
|
35
|
+
'MachineStatus',
|
|
36
|
+
'MoveMode',
|
|
37
|
+
'Status',
|
|
38
|
+
'Endstop',
|
|
39
|
+
'PrintStatus',
|
|
40
|
+
'ThumbnailInfo',
|
|
41
|
+
]
|