Skip to content

Commit 3443904

Browse files
committed
qtvcp -probe sub program: record motion moides befoore and reset after probing
probing must run be in the machine based mode. we use m70/72 to keep track of motion mode to do this without permanently changing the user's mode.
1 parent 2332bb1 commit 3443904

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

lib/python/qtvcp/widgets/probe_subprog.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,16 @@ def process_command(self, cmd):
164164
cmd = cmd.rstrip().split('$')
165165
if cmd[0] in dir(self):
166166
if not STATUS.is_on_and_idle(): return None
167+
pre = self.prechecks()
168+
if pre is not None: return pre
167169
parms = json.loads(cmd[1])
168170
self.update_data(parms)
169171
# start polling errors here - parent program should have blocked their polling
170172
STATUS.unblock_error_polling()
171173
error = self[cmd[0]]()
172174
if (error != 1 or type(error)== str) and STATUS.is_on_and_idle():
173175
ACTION.CALL_MDI("G90")
176+
self.postreset()
174177
return error
175178
else:
176179
return None
@@ -211,6 +214,24 @@ def collect_status(self):
211214
# self.send_dict.update( {key: data} )
212215
#return
213216

217+
# need to be in the right mode - entries are in machine units
218+
def prechecks(self):
219+
if INFO.MACHINE_IS_METRIC and STATUS.is_metric_mode():
220+
return None
221+
if not INFO.MACHINE_IS_METRIC and not STATUS.is_metric_mode():
222+
return None
223+
# record motion modes
224+
ACTION.CALL_MDI('M70')
225+
if INFO.MACHINE_IS_METRIC:
226+
ACTION.CALL_MDI('g21')
227+
else:
228+
ACTION.CALL_MDI('g20')
229+
return None
230+
231+
# return to previous motion modes
232+
def postreset(self):
233+
ACTION.CALL_MDI('M72')
234+
214235
########################################
215236
# required boiler code
216237
########################################

0 commit comments

Comments
 (0)