Skip to content

Commit 4006ef4

Browse files
committed
qtvcp/gladevcp -action: add ability; return to mode after INI mdi
1 parent b6244e5 commit 4006ef4

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

lib/python/gladevcp/gtk_action.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def CALL_MDI_WAIT(self, code, time=5, mode_return=False):
191191
self.ensure_mode(premode)
192192
return 0
193193

194-
def CALL_INI_MDI(self, key):
194+
def CALL_INI_MDI(self, key, mode_return = False):
195195
try:
196196
# prefer named INI MDI commands
197197
mdi = INFO.get_ini_mdi_command(key)
@@ -209,11 +209,21 @@ def CALL_INI_MDI(self, key):
209209

210210

211211
mdi_list = mdi.split(';')
212+
if mode_return:
213+
self.RECORD_CURRENT_MODE()
214+
self._a = STATUS.connect('command-stopped', lambda w: self.return_mode_after_finish())
212215
self.ensure_mode(linuxcnc.MODE_MDI)
213216
for code in (mdi_list):
214217
LOG.debug('CALL_INI_MDI command:{}'.format(code))
215218
self.cmd.mdi('%s' % code)
216219

220+
# when command stops - we try to continue the generator.
221+
# if generator is done - return to recorded mode.
222+
def return_mode_after_finish(self):
223+
print('ini command end')
224+
self.RESTORE_RECORDED_MODE()
225+
STATUS.handler_disconnect(self._a)
226+
217227
def CALL_OWORD(self, code, time=5):
218228
LOG.debug('OWORD_COMMAND= {}'.format(code))
219229
self.ensure_mode(linuxcnc.MODE_MDI)

lib/python/qtvcp/qt_action.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def CALL_MDI_WAIT(self, code, time=5, mode_return=False):
227227
self.ensure_mode(premode)
228228
return 0
229229

230-
def CALL_INI_MDI(self, key):
230+
def CALL_INI_MDI(self, key, mode_return = False):
231231
try:
232232
# prefer named INI MDI commands
233233
mdi = INFO.get_ini_mdi_command(key)
@@ -244,11 +244,21 @@ def CALL_INI_MDI(self, key):
244244
return
245245

246246
mdi_list = mdi.split(';')
247+
if mode_return:
248+
self.RECORD_CURRENT_MODE()
249+
self._a = STATUS.connect('command-stopped', lambda w: self.return_mode_after_finish())
247250
self.ensure_mode(linuxcnc.MODE_MDI)
248251
for code in (mdi_list):
249252
LOG.debug('CALL_INI_MDI command:{}'.format(code))
250253
self.cmd.mdi('%s' % code)
251254

255+
# when command stops - we try to continue the generator.
256+
# if generator is done - return to recorded mode.
257+
def return_mode_after_finish(self):
258+
print('ini command end')
259+
self.RESTORE_RECORDED_MODE()
260+
STATUS.handler_disconnect(self._a)
261+
252262
def CALL_OWORD(self, code, time=5):
253263
LOG.debug('OWORD_COMMAND= {}'.format(code))
254264
self.ensure_mode(linuxcnc.MODE_MDI)

0 commit comments

Comments
 (0)