Skip to content

Commit

Permalink
Fix lock when print ends while skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
paukstelis committed Aug 13, 2020
1 parent b1f3018 commit b967a50
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions octoprint_cancelobject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ def _matchComment(self, line):
for pattern in self.patterns:
matched = pattern.match(line)
if matched:
obj = matched.group(1)
line = "{0} {1}\n".format(self._reptag, obj.encode('ascii','xmlcharrefreplace'))
obj = matched.group(1).encode('ascii','xmlcharrefreplace')
line = "{0} {1}\n".format(self._reptag, obj.decode('utf-8'))
#Match SuperSlicer Object information
info = self.infomatch.match(line)
if info:
objinfo = json.loads(info.group(0)[9:])
line = "{0}info {1} X{2} Y{3}\n".format(self._reptag, objinfo['id'], objinfo['object_center'][0], objinfo['object_center'][1])
objname = objinfo['id'].encode('ascii','xmlcharrefreplace')
line = "{0}info {1} X{2} Y{3}\n".format(self._reptag, objname.decode('utf-8'), objinfo['object_center'][0], objinfo['object_center'][1])

#Match PrusaSlicer/SuperSlicer stop printing comments
stop = self.stopmatch.match(line)
Expand Down Expand Up @@ -252,10 +253,10 @@ def on_api_command(self, command, data):
if command == "resetpos":
if not self.objects_known:
for obj in self.object_list:
obj["max_x"] = 0;
obj["max_y"] = 0;
obj["min_x"] = 10000;
obj["min_y"] = 10000;
obj["max_x"] = 0
obj["max_y"] = 0
obj["min_x"] = 10000
obj["min_y"] = 10000

def on_api_get(self, request):
self._updateobjects()
Expand Down Expand Up @@ -292,6 +293,10 @@ def on_event(self, event, payload):
self._updateobjects()

elif event in (Events.PRINT_DONE, Events.PRINT_FAILED, Events.PRINT_CANCELLED, Events.FILE_DESELECTED):
if self.skipping:
self.skipping = False
self._printer.set_temperature('bed', 0)
self._printer.set_temperature('tool0', 0)
self.object_list = []
self.objects_known = False
self.trackE = False
Expand Down Expand Up @@ -430,6 +435,9 @@ def check_queue(self, comm_instance, phase, cmd, cmd_type, gcode, tags, *args, *
# Need this or @ commands get caught in skipping block
#if self._check_object(cmd):
# return cmd
if not self._printer.is_printing():
return cmd

if cmd.startswith("@"):
return cmd

Expand Down
Binary file modified octoprint_cancelobject/__init__.pyc
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-Cancelobject"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.4.2"
plugin_version = "0.4.3"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit b967a50

Please sign in to comment.