Commit 810cebec authored by Guillaume Seguin's avatar Guillaume Seguin

Integrate host commands in pronsole and pronterface (#428)

Any host command (other than pause) will now be run as a pronsole
command. This will allow doing things such as #428 easily.
parent dbf8ea3b
......@@ -445,6 +445,7 @@ class pronsole(cmd.Cmd):
self.p.startcb = self.startcb
self.p.endcb = self.endcb
self.p.layerchangecb = self.layer_change_cb
self.p.process_host_command = self.process_host_command
self.recvlisteners = []
self.in_macro = False
self.p.onlinecb = self.online
......@@ -1636,6 +1637,14 @@ class pronsole(cmd.Cmd):
def help_off(self):
self.log(_("Turns off everything on the printer"))
def process_host_command(self, command):
"""Override host command handling"""
command = command.lstrip()
if command.startswith(";@"):
command = command[2:]
self.log(_("G-Code calling host command \"%s\"") % command)
self.onecmd(command)
def add_cmdline_arguments(self, parser):
parser.add_argument('-c', '--conf', '--config', help = _("load this file on startup instead of .pronsolerc ; you may chain config files, if so settings auto-save will use the last specified file"), action = "append", default = [])
parser.add_argument('-e', '--execute', help = _("executes command after configuration/.pronsolerc is loaded ; macros/settings from these commands are not autosaved"), action = "append", default = [])
......
......@@ -177,9 +177,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.xy_feedrate = self.settings.xy_feedrate
self.p.z_feedrate = self.settings.z_feedrate
#make printcore aware of me
self.p.pronterface = self
self.panel.SetBackgroundColour(self.settings.bgcolor)
customdict = {}
try:
......@@ -1391,6 +1388,14 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
## Printcore callbacks
## --------------------------------------------------------------
def process_host_command(self, command):
"""Override host command handling"""
command = command.lstrip()
if command.startswith(";@pause"):
self.pause(None)
else:
pronsole.pronsole.process_host_command(self, command)
def startcb(self, resuming = False):
"""Callback on print start"""
pronsole.pronsole.startcb(self, resuming)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment