Skip to content

Commit a08c40d

Browse files
committed
fix tool change
continue comments
1 parent 705b217 commit a08c40d

File tree

5 files changed

+129
-122
lines changed

5 files changed

+129
-122
lines changed

Actions/actions.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def processAction(self, msg):
6262
elif msg["data"]["command"] == "shutdown":
6363
if not self.shutdown():
6464
self.data.ui_queue1.put("Alert", "Alert", "Error with shutting down.")
65-
elif self.data.uploadFlag:
65+
elif self.data.uploadFlag > 0:
6666
self.data.ui_queue1.put("Alert", "Alert", "Cannot issue command while sending gcode.")
6767
# Commands not allowed during sending gcode.. if you did these commands, something could screw up.
6868
# If uploadFlag was enabled (see above) then this would never be reached.
@@ -516,11 +516,8 @@ def pauseRun(self):
516516
self.data.uploadFlag = 0
517517
self.data.console_queue.put("Run Paused")
518518
self.data.ui_queue1.put("Action", "setAsResume", "")
519-
# I don't think this is actually used, but the idea was to be able to make sure the machine returns to
519+
# The idea was to be able to make sure the machine returns to
520520
# the correct z-height after a pause in the event the user raised/lowered the bit.
521-
# However, in the resumeRun function, that doesn't occur unless manualZAxisAdjust is set, which only
522-
# occurs when a tool change in issued. So, perhaps we need to add self.data.manualZAxisAdjust enabled
523-
# here as well if that's what we want it to do.
524521
self.data.pausedzval = self.data.zval
525522
return True
526523
except Exception as e:
@@ -537,6 +534,7 @@ def resumeRun(self):
537534
'''
538535
try:
539536
# if a tool change, then...
537+
print("at resume run with manualzaxisadjust = "+str(self.data.manualZAxisAdjust))
540538
if self.data.manualZAxisAdjust:
541539
# make sure the units match what they were
542540
if self.data.pausedUnits != self.data.units:
@@ -547,16 +545,23 @@ def resumeRun(self):
547545
# move the z-axis back to where it was.
548546
# note: this does not work correctly in relative mode.
549547
# Todo: somehow manke this work when controller is in relative mode (G91)
548+
print("sending pausedzval equal to "+str(self.data.pausedzval)+" from resumeRun")
550549
self.data.gcode_queue.put("G0 Z" + str(self.data.pausedzval) + " ")
551550
# clear the flag since resume
552551
self.data.manualZAxisAdjust = False
553552
# reenable the uploadFlag if it was previous set.
554-
self.data.uploadFlag = self.data.previousUploadStatus ### just moved this here from after if statement
553+
if self.data.previousUploadStatus == -1:
554+
# if was M command pause, then set to 1
555+
self.data.uploadFlag = 1
556+
else:
557+
self.data.uploadFlag = self.data.previousUploadStatus ### just moved this here from after if statement
555558
else:
559+
print("sending pausedzval equal to "+str(self.data.pausedzval)+" from resumeRun without manual change")
560+
self.data.gcode_queue.put("G0 Z" + str(self.data.pausedzval) + " ")
556561
self.sendGCodePositionUpdate(self.data.gcodeIndex, recalculate=True)
557562
self.data.uploadFlag = 1
558563
# send cycle resume command to unpause the machine
559-
# todo: delete this if not needed.
564+
# needed only if user initiated pause, but doesn't actually cause harm to controller.
560565
self.data.quick_queue.put("~")
561566
self.data.ui_queue1.put("Action", "setAsPause", "")
562567
return True
@@ -1561,6 +1566,7 @@ def processGCode(self):
15611566
self.data.actions.updateSetting("toMM", 0, True) # value = doesn't matter
15621567
'''
15631568
# move the Z-axis to the safe height
1569+
print("moving to safe height as part of processgcode")
15641570
self.data.gcode_queue.put("G0 Z"+str(round(zAxisSafeHeight, 4))+" ")
15651571
# move the sled to the x, y coordinate it is supposed to be.
15661572
self.data.gcode_queue.put("G0 X"+str(round(xpos, 4))+" Y"+str(round(ypos, 4))+" ")
@@ -1577,6 +1583,7 @@ def processGCode(self):
15771583
if dwell is not None:
15781584
self.data.gcode_queue.put("G4 "+dwell)
15791585
# move the z-axis to where it is supposed to be.
1586+
print("moving to where it should be as part of processgcode")
15801587
self.data.gcode_queue.put("G0 Z" + str(round(zpos, 4)) + " ")
15811588
# finally, put the machine in the appropriate positioning
15821589
# I have no idea if this really works for G91 gcode files..
@@ -1747,7 +1754,7 @@ def velocityPIDTestRun(self, command, msg):
17471754
17481755
:param command:
17491756
:param msg:
1750-
:return:
1757+
:return:
17511758
'''
17521759
try:
17531760
if command == 'stop':

Background/UIProcessor.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ def start(self, _app):
7878
self.setErrorOnScreen(message)
7979
elif message[0:13] == "Maslow Paused":
8080
# Maslow has been paused. set uploadFlag to 0 and update the pause button on the
81-
# UI clients
81+
# UI clients. In reality, uploadFlag should already be set to 0 by serialPortThread
82+
# that is, the controller shouldn't be pausing without webcontrol already know it's
83+
# going to pause.
8284
self.app.data.uploadFlag = 0
83-
# todo: this needs to be fixed. only way i can move z axis after a tool change
85+
# Send '~' upon receiveing the "Maslow Paused" notification. This
8486
# operation is to issue this 'un-pause' command which then lets two ok's to come back
8587
# (one for the tool change and one for the ~) Without this, serialThread won't see
8688
# that the bufferSize = bufferSpace and therefore won't issue any commands.

0 commit comments

Comments
 (0)