@@ -226,7 +226,9 @@ def arretUrgence():
226
226
self .ui .mnuConfirm_Go_to_G30 .triggered .connect (self .on_mnuConfirm_Go_to_G30 )
227
227
self .ui .mnuConfirm_define_G28 .triggered .connect (self .on_mnuConfirm_define_G28 )
228
228
self .ui .mnuConfirm_define_G30 .triggered .connect (self .on_mnuConfirm_define_G30 )
229
-
229
+ self .ui .mnuPrefToolChange .triggered .connect (self .on_mnuPrefToolChange )
230
+ self .ui .mnuIgnoreFirstToolChange .triggered .connect (self .on_mnuIgnoreFirstToolChange )
231
+
230
232
self .ui .mnuAppQuitter .triggered .connect (self .on_mnuAppQuitter )
231
233
232
234
self .ui .mnu_GrblConfig .triggered .connect (self .on_mnu_GrblConfig )
@@ -245,7 +247,7 @@ def arretUrgence():
245
247
self .ui .mnuSaveG92 .triggered .connect (self .on_mnuSaveG92 )
246
248
self .ui .mnuRestoreG92 .triggered .connect (self .on_mnuRestoreG92 )
247
249
self .ui .mnuG92_1 .triggered .connect (self .on_mnuG92_1 )
248
-
250
+
249
251
self .ui .mnuJog_to .triggered .connect (self .on_mnuJog_to )
250
252
self .ui .mnuToolChange .triggered .connect (self .on_mnuToolChange )
251
253
@@ -383,6 +385,7 @@ def arretUrgence():
383
385
self .ui .btnSetOriginZ .clicked .connect (self .on_btnSetOriginZ )
384
386
self .ui .chkSeekZ .clicked .connect (self .on_chkSeekZ )
385
387
self .ui .chkSeekXY .clicked .connect (self .on_chkSeekXY )
388
+ self .ui .chkInvertProbePinZ .clicked .connect (self .on_chkInvertProbePinZ )
386
389
387
390
# Onglet probe XY
388
391
self .ui .dsbToolDiameter .valueChanged .connect (self .on_dsbToolDiameterValueChanged )
@@ -405,6 +408,7 @@ def arretUrgence():
405
408
self .ui .btnHomePlusX .clicked .connect (lambda : self .on_btnHomeXY ("plusX" ))
406
409
self .ui .btnHomePlusY .clicked .connect (lambda : self .on_btnHomeXY ("plusY" ))
407
410
self .ui .btnResetResults .clicked .connect (self .resetProbeResults )
411
+ self .ui .chkInvertProbePinXY .clicked .connect (self .on_chkInvertProbePinXY )
408
412
409
413
#--------------------------------------------------------------------------------------
410
414
# Traitement des arguments de la ligne de commande
@@ -438,15 +442,16 @@ def arretUrgence():
438
442
439
443
# Initialise la boite de progression d'un fichier programme GCode
440
444
self .__pBox = qwProgressBox (self )
441
- self .__pBoxArmee = False
445
+ self .__pBox . setDecoder ( self . __decode )
442
446
443
447
# Restore le curseur souris sablier en fin d'initialisation
444
448
QtWidgets .QApplication .restoreOverrideCursor ()
445
449
446
450
### GBGB tests ###
447
451
###print(locale.getlocale(locale.LC_TIME))
448
452
###print(datetime.now().strftime("%A %x %H:%M:%S"))
449
- ### Pour debug de qwProgressBox ### self.__pBox.start()
453
+ ### Pour debug de qwProgressBox
454
+ ###self.__pBox.start()
450
455
451
456
452
457
def populatePortList (self ):
@@ -679,6 +684,8 @@ def on_mnuPreferences(self):
679
684
self .ui .mnuConfirm_Go_to_G30 .setChecked (not self .__settings .value ("dontConfirmG30" , False , type = bool ))
680
685
self .ui .mnuConfirm_define_G28 .setChecked (not self .__settings .value ("dontConfirmG28.1" , False , type = bool ))
681
686
self .ui .mnuConfirm_define_G30 .setChecked (not self .__settings .value ("dontConfirmG30.1" , False , type = bool ))
687
+ self .ui .mnuPrefToolChange .setChecked (self .__settings .value ("useToolChange" , True , type = bool ))
688
+ self .ui .mnuIgnoreFirstToolChange .setChecked (self .__settings .value ("ignoreFirstToolChange" , False , type = bool ))
682
689
683
690
684
691
@pyqtSlot ()
@@ -701,6 +708,16 @@ def on_mnuConfirm_define_G30(self):
701
708
self .__settings .setValue ("dontConfirmG30.1" , not self .ui .mnuConfirm_define_G30 .isChecked ())
702
709
703
710
711
+ @pyqtSlot ()
712
+ def on_mnuPrefToolChange (self ):
713
+ self .__settings .setValue ("useToolChange" , self .ui .mnuPrefToolChange .isChecked ())
714
+
715
+
716
+ @pyqtSlot ()
717
+ def on_mnuIgnoreFirstToolChange (self ):
718
+ self .__settings .setValue ("ignoreFirstToolChange" , self .ui .mnuIgnoreFirstToolChange .isChecked ())
719
+
720
+
704
721
@pyqtSlot ()
705
722
def on_mnuAppQuitter (self ):
706
723
self .close ()
@@ -880,10 +897,6 @@ def on_dlgJogFinished(self):
880
897
def on_mnuToolChange (self ):
881
898
''' Appel de la boite de dialogue de changement d'outils '''
882
899
RC = self .__dlgToolChange .showDialog ()
883
- if RC == QtWidgets .QDialog .Accepted :
884
- print ("Changement d'outil OK" )
885
- else :
886
- print ("Changement d'outil annulé" )
887
900
888
901
889
902
@pyqtSlot ()
@@ -977,6 +990,9 @@ def on_qtabMain_currentChanged(self, tabIndex):
977
990
self .ui .rbtMove2PointAfterXY .setChecked (self .__settings .value ("Probe/go2PointXY" , DEFAULT_PROBE_GO_2_POINT_AFTER_XY , type = bool ))
978
991
self .ui .rbtRetractAfterXY .setChecked (self .__settings .value ("Probe/RetractAfterXY" , DEFAULT_PROBE_RETRACT_AFTER_XY , type = bool ))
979
992
self .ui .dsbRetractXY .setValue (self .__settings .value ("Probe/RetractDistanceXY" , DEFAULT_PROBE_RETRACT_DISTANCE_AFTER_XY , type = float ))
993
+ # case a cocher invert probe pin
994
+ if self .__decode .getGrblSetting (6 ) is not None :
995
+ self .ui .chkInvertProbePinXY .setChecked ((int (self .__decode .getGrblSetting (6 )) == 1 ))
980
996
981
997
elif tabIndex == CN5X_TAB_PROBE_Z :
982
998
self .ui .dsbDistanceZ .setValue (self .__settings .value ("Probe/DistanceZ" , DEFAULT_PROBE_DISTANCE , type = float ))
@@ -995,6 +1011,9 @@ def on_qtabMain_currentChanged(self, tabIndex):
995
1011
self .ui .dsbToolLengthSensorZ .setValue (self .__settings .value ("Probe/ToolChangePositionZ" , DEFAULT_TOOLCHANGE_POSITION_Z , type = float ))
996
1012
self .ui .dsbToolLengthSensorX .setValue (self .__settings .value ("Probe/ToolChangePositionX" , DEFAULT_TOOLCHANGE_POSITION_X , type = float ))
997
1013
self .ui .dsbToolLengthSensorY .setValue (self .__settings .value ("Probe/ToolChangePositionY" , DEFAULT_TOOLCHANGE_POSITION_Y , type = float ))
1014
+ # case a cocher invert probe pin
1015
+ if self .__decode .getGrblSetting (6 ) is not None :
1016
+ self .ui .chkInvertProbePinZ .setChecked ((int (self .__decode .getGrblSetting (6 )) == 1 ))
998
1017
999
1018
1000
1019
@pyqtSlot ()
@@ -1841,6 +1860,26 @@ def on_chkSeekXY(self):
1841
1860
self .ui .dsbPullOffXY .setEnabled (False )
1842
1861
1843
1862
1863
+ @pyqtSlot ()
1864
+ def on_chkInvertProbePinZ (self ):
1865
+ if self .ui .chkInvertProbePinZ .isChecked ():
1866
+ self .__grblCom .gcodePush ("$6=1" )
1867
+ self .__grblCom .gcodePush (CMD_GRBL_GET_SETTINGS )
1868
+ else :
1869
+ self .__grblCom .gcodePush ("$6=0" )
1870
+ self .__grblCom .gcodePush (CMD_GRBL_GET_SETTINGS )
1871
+
1872
+
1873
+ @pyqtSlot ()
1874
+ def on_chkInvertProbePinXY (self ):
1875
+ if self .ui .chkInvertProbePinXY .isChecked ():
1876
+ self .__grblCom .gcodePush ("$6=1" )
1877
+ self .__grblCom .gcodePush (CMD_GRBL_GET_SETTINGS )
1878
+ else :
1879
+ self .__grblCom .gcodePush ("$6=0" )
1880
+ self .__grblCom .gcodePush (CMD_GRBL_GET_SETTINGS )
1881
+
1882
+
1844
1883
@pyqtSlot (str )
1845
1884
def on_sig_config_changed (self , data : str ):
1846
1885
self .log (logSeverity .info .value , self .tr ("Grbl configuration updated: {}" ).format (data ))
@@ -2205,8 +2244,11 @@ def on_sig_error(self, errNum: int):
2205
2244
self .__cycleRun = False
2206
2245
self .__cyclePause = False
2207
2246
# Masque de la boite de progression
2208
- if self .__pBox .isVisible ():
2209
- self .__pBox .stop ()
2247
+ if self .__pBox .isVisible ():
2248
+ if self .__pBox .autoClose ():
2249
+ self .__pBox .stop ()
2250
+ else :
2251
+ self .__pBox .enableClose ()
2210
2252
2211
2253
2212
2254
@pyqtSlot (int )
@@ -2217,22 +2259,19 @@ def on_sig_alarm(self, alarmNum: int):
2217
2259
self .__grblCom .clearCom () # Vide la file d'attente de communication
2218
2260
self .__cycleRun = False
2219
2261
self .__cyclePause = False
2220
- # Masque de la boite de progression
2221
- if self .__pBox .isVisible ():
2222
- self .__pBox .stop ()
2262
+ # Masque de la boite de progression
2263
+ if self .__pBox .isVisible ():
2264
+ if self .__pBox .autoClose ():
2265
+ self .__pBox .stop ()
2266
+ else :
2267
+ self .__pBox .enableClose ()
2223
2268
2224
2269
2225
2270
@pyqtSlot (str )
2226
2271
def on_sig_status (self , data : str ):
2227
2272
retour = self .__decode .decodeGrblStatus (data )
2228
2273
if retour != "" :
2229
2274
self .logGrbl .append (retour )
2230
- if self .__cycleRun and self .__decode .get_etatMachine () == GRBL_STATUS_RUN :
2231
- self .__pBoxArmee = True
2232
- # Masque de la boite de progression
2233
- if (self .__decode .get_etatMachine () == GRBL_STATUS_IDLE ) and self .__pBox .isVisible () and self .__pBoxArmee :
2234
- #print(self.__decode.get_etatMachine())
2235
- self .__pBox .stop ()
2236
2275
2237
2276
2238
2277
@pyqtSlot (str )
@@ -2282,6 +2321,7 @@ def on_sig_config(self, data: str):
2282
2321
2283
2322
@pyqtSlot (str )
2284
2323
def on_sig_emit (self , data : str ):
2324
+ trouve = False
2285
2325
if data != "" :
2286
2326
self .logGrbl .append (data )
2287
2327
if self .__cycleRun :
@@ -2291,15 +2331,17 @@ def on_sig_emit(self, data: str):
2291
2331
idx = self .ui .gcodeTable .model ().index (ligne , 0 , QModelIndex ())
2292
2332
if self .ui .gcodeTable .model ().data (idx ) == data :
2293
2333
self .__gcodeFile .selectGCodeFileLine (ligne )
2334
+ trouve = True
2294
2335
break
2295
2336
else :
2296
2337
ligne += 1
2297
2338
# Mise à jour de la progressBox
2298
- self .__pBox .setValue (ligne + 1 )
2339
+ if trouve :
2340
+ self .__pBox .setValue (ligne + 1 )
2341
+ # On affiche le dernier commentaire rencontré dans la progressBox
2299
2342
if data [:1 ] == '(' and data [- 1 :] == ")" :
2300
2343
self .__pBox .setComment (data )
2301
2344
2302
-
2303
2345
@pyqtSlot (str )
2304
2346
def on_sig_recu (self , data : str ):
2305
2347
pass
@@ -2383,7 +2425,6 @@ def clearDebug(self):
2383
2425
2384
2426
2385
2427
def startCycle (self , startFrom : int = 0 ):
2386
-
2387
2428
2388
2429
if self .ui .gcodeTable .model ().rowCount ()<= 0 :
2389
2430
self .log (logSeverity .warning .value , self .tr ("Attempt to start an empty cycle..." ))
@@ -2392,18 +2433,34 @@ def startCycle(self, startFrom: int = 0):
2392
2433
2393
2434
# Affichage de la boite de progression
2394
2435
self .__pBox .setRange (startFrom , self .ui .gcodeTable .model ().rowCount ())
2395
- self .__pBoxArmee = False
2396
2436
self .__pBox .start ()
2397
2437
2398
2438
self .__gcodeFile .selectGCodeFileLine (0 )
2399
2439
self .__cycleRun = True
2400
2440
self .__cyclePause = False
2401
-
2441
+
2402
2442
self .__gcodeFile .enQueue (self .__grblCom , startFrom )
2403
-
2404
- self .ui .btnStart .setButtonStatus (True )
2443
+
2444
+ # Attente de la fin du traitement par Grbl
2445
+ tDebut = time .time ()
2446
+ while (time .time () - tDebut ) * 1000 < 2 * GRBL_QUERY_DELAY :
2447
+ QCoreApplication .processEvents ()
2448
+ while self .__decode .get_etatMachine () != GRBL_STATUS_IDLE :
2449
+ QCoreApplication .processEvents ()
2450
+
2451
+ self .log (logSeverity .info .value , self .tr ("Cycle completed." ))
2452
+
2453
+ self .__pBox .setComment (self .tr ("GCode finished at: {}" ).format (datetime .now ().strftime ("%A %x %H:%M:%S" )))
2454
+
2455
+ self .ui .btnStart .setButtonStatus (False )
2405
2456
self .ui .btnPause .setButtonStatus (False )
2406
- self .ui .btnStop .setButtonStatus (False )
2457
+ self .ui .btnStop .setButtonStatus (True )
2458
+
2459
+ if self .__pBox .isVisible ():
2460
+ if self .__pBox .autoClose ():
2461
+ self .__pBox .stop ()
2462
+ else :
2463
+ self .__pBox .enableClose ()
2407
2464
2408
2465
2409
2466
def pauseCycle (self ):
@@ -2454,11 +2511,15 @@ def stopCycle(self):
2454
2511
self .__cycleRun = False
2455
2512
self .__cyclePause = False
2456
2513
# Masque de la boite de progression
2457
- self .__pBox .stop ()
2514
+ if self .__pBox .isVisible ():
2515
+ if self .__pBox .autoClose ():
2516
+ self .__pBox .stop ()
2517
+ else :
2518
+ self .__pBox .enableClose ()
2458
2519
self .ui .btnStart .setButtonStatus (False )
2459
2520
self .ui .btnPause .setButtonStatus (False )
2460
2521
self .ui .btnStop .setButtonStatus (True )
2461
- self .log (logSeverity .info .value , self .tr ("Cycle completed ." ))
2522
+ self .log (logSeverity .info .value , self .tr ("Cycle stopped ." ))
2462
2523
2463
2524
2464
2525
def on_gcodeTableContextMenu (self , event ):
0 commit comments