Skip to content

Commit

Permalink
Allow clear queue on cancel to be conditional
Browse files Browse the repository at this point in the history
Add warning highlight to verbose setting
  • Loading branch information
markwal committed Jul 8, 2015
1 parent 3aa6e1d commit 5be01fc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion GPX
8 changes: 6 additions & 2 deletions octoprint_GPX/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_extension_tree(self, *args, **kwargs):
)

def get_settings_defaults(self):
return dict(enabled=True, prerelease=False, verbose=False, connection_pause=2.0)
return dict(enabled=True, prerelease=False, verbose=False, connection_pause=2.0, clear_queue_on_cancel=True)

def on_settings_save(self, data):
# do the super, see https://thingspython.wordpress.com/2010/09/27/another-super-wrinkle-raising-typeerror
Expand All @@ -112,10 +112,14 @@ def on_settings_save(self, data):
self.printer.refresh_ini()

def on_event(self, event, payload):
# normally OctoPrint will merely stop sending commands on a cancel this
# means that whatever is in the printer's queue will complete including
# ten minutes to heat up the print bed; we circumvent here by telling
# the bot to stop
if event == Events.PRINT_CANCELLED:
if self.printer:
# jump the queue with an abort
self.printer.write("M112");
self.printer.cancel()

def get_assets(self):
return dict(
Expand Down
40 changes: 26 additions & 14 deletions octoprint_GPX/gpxprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def write(self, data):
except ValueError:
self.baudrateError = True
self.outgoing.put('')
pass
return

# look for a line number
Expand All @@ -84,18 +83,21 @@ def write(self, data):
gpx.write("M136")

# try to talk to the bot
while True:
try:
if match is None:
reprapSave = gpx.reprap_flavor(True)
self._append(gpx.write("%s" % data))
break
except gpx.BufferOverflow:
time.sleep(0.1)
pass
finally:
if match is None:
gpx.reprap_flavor(reprapSave)
try:
if match is None:
reprapSave = gpx.reprap_flavor(True)

# loop sending until the queue isn't full
while True:
try:
self._append(gpx.write("%s" % data))
break
except gpx.BufferOverflow:
time.sleep(0.1)

finally:
if match is None:
gpx.reprap_flavor(reprapSave)

def readline(self):
while (self.baudrateError):
Expand Down Expand Up @@ -124,9 +126,19 @@ def readline(self):
if append_later is not None:
self._append(append_later)
self._logger.debug("timeout")
pass
return ''

def cancel(self):
# loop sending until the queue isn't full
while True:
try:
self._append(gpx.cancel(self._settings.get_boolean(['clear_queue_on_cancel'])))
break
except gpx.BufferOverflow:
time.sleep(0.1)
# tell octoprint to ok to send
self._append("ok")

def close(self):
gpx.disconnect()
return
4 changes: 2 additions & 2 deletions octoprint_GPX/templates/GPX_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<input type="checkbox" data-bind="checked: settings.plugins.GPX.prerelease"> {{ _('Show pre-release updates') }}
</label>
</div>
<div class="controls" data-toggle="tooltip" title="{{ _('Tell the GPX gcode processor to be more verbose in the plugin log') }}">
<div class="controls" data-toggle="tooltip" title="{{ _('Tell the GPX gcode processor to be more verbose in the plugin log. Warning, *very* verbose and GPX log deletion is manual on the Logs pane.') }}">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.GPX.verbose"> {{ _('Verbose GPX logging') }}
<input type="checkbox" data-bind="checked: settings.plugins.GPX.verbose"> {{ _('Verbose GPX logging') }}&nbsp;<span class="label label-important">{{ _('Warning') }}</span>
</label>
</div>
</div>
Expand Down

0 comments on commit 5be01fc

Please sign in to comment.