MCPcopy Create free account
hub / github.com/FullControlXYZ/fullcontrol / State

Class State

fullcontrol/gcode/state.py:13–85  ·  view source on GitHub ↗

This class tracks the state of instances of interest adjusted in the list of steps (points, extruder, etc.). It also includes some relevant shared variables and initialization methods. Upon instantiation, a list of steps and GcodeControls must be passed to allow initialization of

Source from the content-addressed store, hash-verified

11
12
13class State(BaseModel):
14 '''
15 This class tracks the state of instances of interest adjusted in the list
16 of steps (points, extruder, etc.). It also includes some relevant shared variables and
17 initialization methods. Upon instantiation, a list of steps and GcodeControls must be passed
18 to allow initialization of various attributes.
19
20 Attributes:
21 extruder (Optional[Extruder]): The extruder instance.
22 printer (Optional[Printer]): The printer instance.
23 extrusion_geometry (Optional[ExtrusionGeometry]): The extrusion geometry instance.
24 steps (Optional[list]): The list of steps.
25 point (Optional[Point]): The current point.
26 i (Optional[int]): The current index.
27 gcode (Optional[list]): The list of Gcode.
28
29 Methods:
30 __init__: Initializes the State object.
31
32 '''
33
34 extruder: Optional[Extruder] = None
35 printer: Optional[Printer] = None
36 extrusion_geometry: Optional[ExtrusionGeometry] = None
37 steps: Optional[list] = None
38 point: Optional[Point] = Point()
39 i: Optional[int] = 0
40 gcode: Optional[list] = []
41
42 def __init__(self, steps: list, gcode_controls: GcodeControls):
43 """
44 Initializes a State object.
45
46 Args:
47 steps (list): A list of steps for the state.
48 gcode_controls (GcodeControls): An instance of the GcodeControls class.
49
50 Returns:
51 None
52 """
53 super().__init__()
54 # initialize state based on the named-printer default initialization_data and initialization_data over-rides passed by designer in gcode_controls
55
56 if gcode_controls.printer_name[:5] == 'Cura/' or gcode_controls.printer_name[:10] == 'Community/':
57 initialization_data = import_printer(gcode_controls.printer_name, gcode_controls.initialization_data)
58 # note if using 'no_primer' there is a risk that no initial Point is defined before the first G1 command meaning length calculation for the line is impossible and an error will occur
59 else:
60 initialization_data = import_module(f'fullcontrol.devices.community.singletool.{gcode_controls.printer_name}').set_up(gcode_controls.initialization_data)
61
62 self.extruder = Extruder(
63 units=initialization_data['e_units'],
64 dia_feed=initialization_data['dia_feed'],
65 total_volume=0,
66 total_volume_ref=0,
67 travel_format=initialization_data['travel_format'])
68 self.extruder.update_e_ratio()
69 if initialization_data['manual_e_ratio'] != None:
70 self.extruder.volume_to_e = initialization_data['manual_e_ratio']

Callers 1

gcodeFunction · 0.90

Calls 1

PointClass · 0.90

Tested by

no test coverage detected