@@ -92,7 +92,6 @@ def __init__(self, parent: QtWidgets.QWidget, printer: Printer, ws, /) -> None:
9292 lambda : self .request_change_tab .emit (0 )
9393 )
9494 self .run_gcode .connect (self .ws .api .run_gcode )
95- self .printer .extruder_update .connect (self .on_extruder_update )
9695 self .printer .unload_filament_update .connect (self .on_unload_filament )
9796 self .printer .load_filament_update .connect (self .on_load_filament )
9897 self .printer .filament_switch_sensor_update .connect (
@@ -103,10 +102,9 @@ def __init__(self, parent: QtWidgets.QWidget, printer: Printer, ws, /) -> None:
103102 self .printer .print_stats_update [str , dict ].connect (self .on_print_stats_update )
104103 self .printer .print_stats_update [str , float ].connect (self .on_print_stats_update )
105104
106- self .loadignore = True
107- self .unloadignore = True
108105
109106 self .printer .save_variables_update .connect (self .on_save_variables_update )
107+ self .state = "standby"
110108
111109 def on_save_variables_update (self , save_variables : dict ):
112110 """Handle query response"""
@@ -125,6 +123,7 @@ def on_print_stats_update(self, field: str, value: dict | float | str) -> None:
125123 """Handle print stats object update"""
126124 if isinstance (value , str ):
127125 if "state" in field :
126+ self .state = value
128127 if value in ("printing" , "pausing" , "paused" , "resuming" ):
129128 self .panel .main_back_button .show ()
130129 self .panel .spacerItem1 .changeSize (
@@ -134,8 +133,6 @@ def on_print_stats_update(self, field: str, value: dict | float | str) -> None:
134133 QtWidgets .QSizePolicy .Policy .Minimum ,
135134 )
136135 if value in ("standby" ):
137- self .loadignore = True
138- self .unloadignore = True
139136 self .panel .main_back_button .hide ()
140137 self .panel .spacerItem1 .changeSize (
141138 0 ,
@@ -160,63 +157,29 @@ def on_filament_sensor_update(self, sensor_name: str, parameter: str, value: boo
160157 return
161158 self .handle_filament_state ()
162159
163- @QtCore .pyqtSlot (str , str , float , name = "on_extruder_update" )
164- def on_extruder_update (
165- self , extruder_name : str , field : str , new_value : float
166- ) -> None :
167- """Handle extruder update"""
168- if not self .isVisible :
169- return
170- if not self .loadignore or not self .unloadignore :
171- if self .target_temp != 0 :
172- if self .current_temp == self .target_temp :
173- if self .isVisible :
174- self .call_load_panel .emit (
175- True , "Extruder heated up \n Please wait"
176- )
177- return
178- if field == "temperature" :
179- self .current_temp = round (new_value , 0 )
180- if self .isVisible :
181- self .call_load_panel .emit (
182- True ,
183- f"Heating up ({ new_value } /{ self .target_temp } ) \n Please wait" ,
184- )
185- if field == "target" :
186- self .target_temp = round (new_value , 0 )
187- if self .isVisible :
188- self .call_load_panel .emit (True , "Heating up \n Please wait" )
189-
190- @QtCore .pyqtSlot (bool , name = "on_load_filament" )
191- def on_load_filament (self , status : bool ):
160+
161+ @QtCore .pyqtSlot (dict , name = "on_load_filament" )
162+ def on_load_filament (self , status : dict ):
192163 """Handle load filament object updated"""
193- if not self .isVisible :
194- return
195- if self .loadignore :
196- return
197- if status :
198- self .call_load_panel .emit (True , "Loading Filament" )
199- else :
200- self .loadignore = True
201- self .target_temp = 0
202- self .call_load_panel .emit (False , "" )
203- self ._filament_state = self .FilamentStates .LOADED
164+ if "state" in status .keys ():
165+ if not status ["state" ]:
166+ self .target_temp = 0
167+ self .call_load_panel .emit (False , "" )
168+ if self .state == "printing" :
169+ self .request_change_tab .emit (0 )
170+ return
171+ self .call_load_panel .emit (True , f"Loading Filament\n { status ['step' ].capitalize ()} " )
204172 self .handle_filament_state ()
205173
206- @QtCore .pyqtSlot (bool , name = "on_unload_filament" )
207- def on_unload_filament (self , status : bool ):
174+ @QtCore .pyqtSlot (dict , name = "on_unload_filament" )
175+ def on_unload_filament (self , status : dict ):
208176 """Handle unload filament object updated"""
209- if not self .isVisible :
210- return
211- if self .unloadignore :
212- return
213- if status :
214- self .call_load_panel .emit (True , "Unloading Filament" )
215- else :
216- self .unloadignore = True
217- self .call_load_panel .emit (False , "" )
218- self .target_temp = 0
219- self ._filament_state = self .FilamentStates .UNLOADED
177+ if "state" in status .keys ():
178+ if not status ["state" ]:
179+ self .target_temp = 0
180+ self .call_load_panel .emit (False , "" )
181+ return
182+ self .call_load_panel .emit (True , f"Unloading Filament\n { status ['step' ].capitalize ()} " )
220183 self .handle_filament_state ()
221184
222185 @QtCore .pyqtSlot (int , int , name = "load_filament" )
@@ -239,7 +202,6 @@ def load_filament(
239202 message = "Filament is already loaded." ,
240203 )
241204 return
242- self .loadignore = False
243205 self .call_load_panel .emit (True , "Loading Filament" )
244206 self .run_gcode .emit (
245207 f"""SAVE_VARIABLE VARIABLE=filament_type VALUE='"{ filament .value .name } "'"""
@@ -268,7 +230,6 @@ def unload_filament(self, toolhead: int = 0, temp: int = 220) -> None:
268230 return
269231
270232 self .find_routine_objects ()
271- self .unloadignore = False
272233 self .call_load_panel .emit (True , "Unloading Filament" )
273234 self .run_gcode .emit (
274235 f"""SAVE_VARIABLE VARIABLE=filament_type VALUE='"{ FilamentTypes .UNKNOWN .value .name } "'"""
0 commit comments