this tracks the state of instances of interest adjusted in the list of steps (points, extruder, etc.). some relevant shared variables and initialisation methods are also included. a list of steps and GcodeControls must be passed upon instantiation to allow initialization of vario
| 12 | |
| 13 | |
| 14 | class State(BaseModel): |
| 15 | ''' this tracks the state of instances of interest adjusted in the list |
| 16 | of steps (points, extruder, etc.). some relevant shared variables and |
| 17 | initialisation methods are also included. a list of steps and |
| 18 | GcodeControls must be passed upon instantiation to allow initialization |
| 19 | of various attributes |
| 20 | ''' |
| 21 | |
| 22 | extruder: Optional[Extruder] = None |
| 23 | printer: Optional[Printer] = None |
| 24 | extrusion_geometry: Optional[ExtrusionGeometry] = None |
| 25 | steps: Optional[list] = None |
| 26 | point: Optional[Point] = Point() |
| 27 | point_systemXYZ: Optional[Point] = Point() |
| 28 | i: Optional[int] = 0 |
| 29 | gcode: Optional[list] = [] |
| 30 | |
| 31 | def __init__(self, steps: list, gcode_controls: GcodeControls): |
| 32 | super().__init__() |
| 33 | # initialize state based on the named-printer default initialization_data and initialization_data over-rides passed by designer in gcode_controls |
| 34 | |
| 35 | def first_XYZBC_point(steps: list, fully_defined: bool = True) -> Point: |
| 36 | 'return first Point in list. if the parameter fully_defined is true, return first Point with all x,y,z,b,c != None' |
| 37 | if type(steps).__name__ == 'list': |
| 38 | for i in range(len(steps)): |
| 39 | if type(steps[i]).__name__ == 'Point': |
| 40 | if fully_defined: |
| 41 | if steps[i].x != None and steps[i].y != None and steps[i].z != None and steps[i].b != None and steps[i].c != None: |
| 42 | return steps[i] |
| 43 | else: |
| 44 | return steps[i] |
| 45 | if fully_defined: |
| 46 | raise Exception(f'No point found in steps with all of x y z b c defined') |
| 47 | if not fully_defined: |
| 48 | raise Exception(f'No point found in steps') |
| 49 | |
| 50 | # the following line was edited from 3-axis gcode since 5-axis gcode is output in a simple form for now |
| 51 | initialization_data = import_module(f'fullcontrol.devices.community.singletool.generic').set_up(gcode_controls.initialization_data) |
| 52 | |
| 53 | self.extruder = Extruder( |
| 54 | units=initialization_data['e_units'], |
| 55 | dia_feed=initialization_data['dia_feed'], |
| 56 | total_volume=0, |
| 57 | total_volume_ref=0, |
| 58 | on=True) # on=True is different from 3-axis gcode since the primer has been disabled |
| 59 | self.extruder.update_e_ratio() |
| 60 | |
| 61 | self.printer = Printer( |
| 62 | command_list=initialization_data['printer_command_list'], |
| 63 | print_speed=initialization_data['print_speed'], |
| 64 | travel_speed=initialization_data['travel_speed'], |
| 65 | bc_intercept=gcode_controls.bc_intercept, # this is added compared to 3-axis gcode |
| 66 | speed_changed=True) |
| 67 | |
| 68 | self.extrusion_geometry = ExtrusionGeometry( |
| 69 | area_model=initialization_data['area_model'], |
| 70 | width=initialization_data['extrusion_width'], |
| 71 | height=initialization_data['extrusion_height']) |