1- VERSION = '014.079 '
1+ VERSION = '015.080 '
22LCNCVER = '2.10'
33
44'''
@@ -1420,6 +1420,8 @@ def power_state(self, state):
14201420 STATUS .emit ('update-machine-log' , log , 'TIME' )
14211421 else :
14221422 self .w .power .setChecked (False )
1423+ if self .tpButton and self .torchPulse :
1424+ self .torch_pulse_abort ()
14231425 self .set_buttons_state ([self .machineOnList , self .idleOnList , self .idleHomedList ], False )
14241426 if self .ptButton and hal .get_value ('plasmac.probe-test' ):
14251427 self .probe_test_stop ()
@@ -2038,9 +2040,7 @@ def abort_pressed(self):
20382040 STATUS .emit ('update-machine-log' , log , 'TIME' )
20392041 return
20402042 elif self .torchPulse :
2041- self .torch_pulse (True )
2042- log = _translate ('HandlerClass' , 'Torch pulse aborted' )
2043- STATUS .emit ('update-machine-log' , log , 'TIME' )
2043+ self .torch_pulse_abort ()
20442044 else :
20452045 ACTION .ABORT ()
20462046 if hal .get_value ('plasmac.cut-recovery' ):
@@ -2735,7 +2735,7 @@ def set_buttons_state(self, buttonLists, state):
27352735 for button in buttonList :
27362736 if state and STATUS .is_interp_paused () and button not in self .pausedValidList :
27372737 continue
2738- if not state and button == self .tpButton and self .torchTimer .isActive ():
2738+ if not state and button == self .tpButton and self .tpTimer .isActive ():
27392739 continue
27402740 self .w [button ].setEnabled (state )
27412741 if self .laserRecStatePin .get ():
@@ -3626,7 +3626,7 @@ def set_button_color(self):
36263626 self .button_normal (button )
36273627
36283628 def cut_critical_toggle_check (self ):
3629- # self.halTogglePins format is: button name, run critical flag, button text
3629+ # self.halTogglePins format is: button name, run critical flag, button text, alt button text
36303630 checkDict = {
36313631 self .halTogglePins [halpin ][2 ].replace ('\n ' , ' ' ): halpin
36323632 for halpin in self .halTogglePins
@@ -3984,23 +3984,19 @@ def probe_timeout(self):
39843984 STATUS .emit ('update-machine-log' , log , 'TIME' )
39853985
39863986 def torch_timeout (self ):
3987- if self .torchTime :
3988- self .torchTime -= 0.1
3989- self .torchTimer .start (100 )
3990- self .w [self .tpButton ].setText (f'{ self .torchTime :.1f} ' )
3991- if self .torchTime <= 0 :
3992- self .torchTimer .stop ()
3993- self .torchTime = 0
3994- if not self .w [self .tpButton ].isDown () and not self .extPulsePin .get ():
3995- self .torch_pulse_states (True )
3996- log = _translate ('HandlerClass' , 'Torch pulse completed' )
3997- STATUS .emit ('update-machine-log' , log , 'TIME' )
3998- else :
3999- text0 = _translate ('HandlerClass' , 'TORCH' )
4000- text1 = _translate ('HandlerClass' , 'ON' )
4001- self .w [self .tpButton ].setText (f'{ text0 } \n { text1 } ' )
3987+ self .tpRemaining = max (0.0 , self .tpRemaining - 0.1 )
3988+ self .w [self .tpButton ].setText (f'{ self .tpRemaining :.1f} ' )
3989+ if self .tpRemaining > 0 :
3990+ return
3991+ self .tpTimer .stop ()
3992+ if not hal .get_value ('plasmac.torch-pulse-hold' ) and not self .extPulsePin .get ():
3993+ self .torch_pulse_states (True )
3994+ log = _translate ('HandlerClass' , 'Torch pulse completed' )
3995+ STATUS .emit ('update-machine-log' , log , 'TIME' )
40023996 else :
4003- self .torchTimer .start (100 )
3997+ text0 = _translate ('HandlerClass' , 'TORCH' )
3998+ text1 = _translate ('HandlerClass' , 'ON' )
3999+ self .w [self .tpButton ].setText (f'{ text0 } \n { text1 } ' )
40044000
40054001 def pulse_timer_timeout (self ):
40064002 # halPulsePins format is: button name, pulse time, button text, remaining time, button number
@@ -4071,10 +4067,11 @@ def user_button_setup(self):
40714067 self .probeTimer = QTimer ()
40724068 self .probeTimer .setSingleShot (True )
40734069 self .probeTimer .timeout .connect (self .probe_timeout )
4074- self .torchTime = 0.0
4075- self .torchTimer = QTimer ()
4076- self .torchTimer .setSingleShot (True )
4077- self .torchTimer .timeout .connect (self .torch_timeout )
4070+ self .tpRemaining = 0.0
4071+ self .tpTimer = QTimer ()
4072+ self .tpTimer .setSingleShot (False )
4073+ self .tpTimer .setInterval (100 )
4074+ self .tpTimer .timeout .connect (self .torch_timeout )
40784075 self .pulseTime = 0
40794076 self .pulseTimer = QTimer ()
40804077 self .pulseTimer .timeout .connect (self .pulse_timer_timeout )
@@ -4163,7 +4160,7 @@ def user_button_setup(self):
41634160 msg1 = _translate ('HandlerClass' , 'Check button code for invalid seconds argument' )
41644161 STATUS .emit ('error' , linuxcnc .OPERATOR_ERROR , f'{ head } :\n { msg0 } #{ bNum } \n { msg1 } \n ' )
41654162 continue
4166- self .tpTime = 3.0 if self .torchTime > 3.0 else self .tpTime
4163+ self .tpTime = 3.0 if self .tpTime > 3.0 else self .tpTime
41674164 else :
41684165 self .tpTime = 1.0
41694166 self .tpButton = f'button_{ str (bNum )} '
@@ -4561,6 +4558,8 @@ def torch_enable_changed(self, state):
45614558 not hal .get_value ('plasmac.consumable-changing' ):
45624559 self .w [self .tpButton ].setEnabled (True )
45634560 else :
4561+ if self .torchPulse :
4562+ self .torch_pulse_abort ()
45644563 self .w [self .tpButton ].setEnabled (False )
45654564
45664565 def ext_torch_enable_changed (self , state ):
@@ -4740,28 +4739,47 @@ def ext_torch_pulse(self, state):
47404739
47414740 def torch_pulse (self , state ):
47424741 if state :
4743- if not self .torchTime and \
4744- self .w .torch_enable .isChecked () and not hal .get_value ('plasmac.torch-on' ):
4745- self .torchTime = self .tpTime
4746- self .torchTimer .start (100 )
4747- self .torchPulse = True
4748- hal .set_p ('plasmac.torch-pulse-time' , str (self .torchTime ))
4749- hal .set_p ('plasmac.torch-pulse-start' , '1' )
4750- self .w [self .tpButton ].setText (f'{ self .torchTime } ' )
4751- self .button_active (self .tpButton )
4752- self .torch_pulse_states (False )
4753- log = _translate ('HandlerClass' , 'Torch pulse started' )
4754- STATUS .emit ('update-machine-log' , log , 'TIME' )
4755- else :
4756- self .torchTimer .stop ()
4757- self .torchTime = 0.0
4758- self .torch_pulse_states (True )
4742+ self .torch_pulse_pressed ()
47594743 else :
4760- hal .set_p ('plasmac.torch-pulse-start' , '0' )
4761- if self .torchTime == 0 :
4762- self .torch_pulse_states (True )
4763- log = _translate ('HandlerClass' , 'Torch pulse ended manually' )
4764- STATUS .emit ('update-machine-log' , log , 'TIME' )
4744+ self .torch_pulse_released ()
4745+
4746+ def torch_pulse_pressed (self ):
4747+ # second press while active aborts
4748+ if self .tpRemaining > 0 :
4749+ self .torch_pulse_abort ()
4750+ return
4751+ if hal .get_value ('plasmac.torch-on' ):
4752+ return
4753+ self .tpRemaining = self .tpTime
4754+ self .torchPulse = True
4755+ hal .set_p ('plasmac.torch-pulse-time' , str (self .tpRemaining ))
4756+ hal .set_p ('plasmac.torch-pulse-start' , '1' )
4757+ hal .set_p ('plasmac.torch-pulse-hold' , '1' )
4758+ self .tpTimer .start ()
4759+ self .w [self .tpButton ].setText (f'{ self .tpRemaining } ' )
4760+ self .button_active (self .tpButton )
4761+ self .torch_pulse_states (False )
4762+ log = _translate ('HandlerClass' , 'Torch pulse started' )
4763+ STATUS .emit ('update-machine-log' , log , 'TIME' )
4764+
4765+ def torch_pulse_released (self ):
4766+ hal .set_p ('plasmac.torch-pulse-start' , '0' )
4767+ hal .set_p ('plasmac.torch-pulse-hold' , '0' )
4768+ if self .tpRemaining == 0 :
4769+ self .torch_pulse_states (True )
4770+ log = _translate ('HandlerClass' , 'Torch pulse hold released' )
4771+ STATUS .emit ('update-machine-log' , log , 'TIME' )
4772+
4773+ def torch_pulse_abort (self ):
4774+ hal .set_p ('plasmac.torch-pulse-abort' , '1' )
4775+ QTimer .singleShot (50 , lambda : hal .set_p ('plasmac.torch-pulse-abort' , '0' ))
4776+ hal .set_p ('plasmac.torch-pulse-start' , '0' )
4777+ hal .set_p ('plasmac.torch-pulse-hold' , '0' )
4778+ self .tpTimer .stop ()
4779+ self .tpRemaining = 0.0
4780+ self .torch_pulse_states (True )
4781+ log = _translate ('HandlerClass' , 'Torch pulse aborted' )
4782+ STATUS .emit ('update-machine-log' , log , 'TIME' )
47654783
47664784 def torch_pulse_states (self , state ):
47674785 self .set_tab_jog_states (state )
@@ -4773,7 +4791,6 @@ def torch_pulse_states(self, state):
47734791 if self .w .gcode_display .lines () > 1 :
47744792 self .w .run .setEnabled (state )
47754793 if state :
4776- hal .set_p ('plasmac.torch-pulse-time' , '0' )
47774794 self .w [self .tpButton ].setText (self .tpText )
47784795 self .button_normal (self .tpButton )
47794796 self .torchPulse = False
0 commit comments