Commit 8d85523a authored by Guillaume Seguin's avatar Guillaume Seguin

Move ETA computations to pronsole

parent de64c43b
...@@ -28,7 +28,8 @@ import logging ...@@ -28,7 +28,8 @@ import logging
from . import printcore from . import printcore
from printrun.printrun_utils import install_locale, run_command, \ from printrun.printrun_utils import install_locale, run_command, \
format_time, format_duration, get_home_pos, parse_build_dimensions format_time, format_duration, RemainingTimeEstimator, \
get_home_pos, parse_build_dimensions
install_locale('pronterface') install_locale('pronterface')
from printrun import gcoder from printrun import gcoder
...@@ -417,10 +418,12 @@ class pronsole(cmd.Cmd): ...@@ -417,10 +418,12 @@ class pronsole(cmd.Cmd):
self.completekey = None self.completekey = None
self.status = Status() self.status = Status()
self.dynamic_temp = False self.dynamic_temp = False
self.compute_eta = None
self.p = printcore.printcore() self.p = printcore.printcore()
self.p.recvcb = self.recvcb self.p.recvcb = self.recvcb
self.p.startcb = self.startcb self.p.startcb = self.startcb
self.p.endcb = self.endcb self.p.endcb = self.endcb
self.p.layerchangecb = self.layer_change_cb
self.recvlisteners = [] self.recvlisteners = []
self.in_macro = False self.in_macro = False
self.p.onlinecb = self.online self.p.onlinecb = self.online
...@@ -1126,6 +1129,7 @@ class pronsole(cmd.Cmd): ...@@ -1126,6 +1129,7 @@ class pronsole(cmd.Cmd):
self.starttime = time.time() self.starttime = time.time()
if resuming: if resuming:
print _("Print resumed at: %s") % format_time(self.starttime) print _("Print resumed at: %s") % format_time(self.starttime)
self.compute_eta = RemainingTimeEstimator(self.fgcode)
else: else:
print _("Print started at: %s") % format_time(self.starttime) print _("Print started at: %s") % format_time(self.starttime)
...@@ -1145,6 +1149,11 @@ class pronsole(cmd.Cmd): ...@@ -1145,6 +1149,11 @@ class pronsole(cmd.Cmd):
stderr = subprocess.STDOUT, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, stdout = subprocess.PIPE,
blocking = False) blocking = False)
def layer_change_cb(self, newlayer):
if self.compute_eta:
secondselapsed = int(time.time() - self.starttime + self.extra_print_time)
self.compute_eta.update_layer(newlayer, secondselapsed)
def help_shell(self): def help_shell(self):
self.log("Executes a python command. Example:") self.log("Executes a python command. Example:")
self.log("! os.listdir('.')") self.log("! os.listdir('.')")
......
...@@ -31,7 +31,7 @@ from . import pronsole ...@@ -31,7 +31,7 @@ from . import pronsole
from . import printcore from . import printcore
from printrun.printrun_utils import install_locale, setup_logging, \ from printrun.printrun_utils import install_locale, setup_logging, \
RemainingTimeEstimator, get_home_pos, parse_build_dimensions get_home_pos
install_locale('pronterface') install_locale('pronterface')
try: try:
...@@ -221,10 +221,8 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -221,10 +221,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.sendcb = self.sentcb self.p.sendcb = self.sentcb
self.p.preprintsendcb = self.preprintsendcb self.p.preprintsendcb = self.preprintsendcb
self.p.printsendcb = self.printsentcb self.p.printsendcb = self.printsentcb
self.p.layerchangecb = self.layer_change_cb
self.p.startcb = self.startcb self.p.startcb = self.startcb
self.p.endcb = self.endcb self.p.endcb = self.endcb
self.compute_eta = None
self.curlayer = 0 self.curlayer = 0
self.cur_button = None self.cur_button = None
self.predisconnect_mainqueue = None self.predisconnect_mainqueue = None
...@@ -249,8 +247,6 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -249,8 +247,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def startcb(self, resuming = False): def startcb(self, resuming = False):
pronsole.pronsole.startcb(self, resuming) pronsole.pronsole.startcb(self, resuming)
if not resuming:
self.compute_eta = RemainingTimeEstimator(self.fgcode)
if self.settings.lockbox and self.settings.lockonstart: if self.settings.lockbox and self.settings.lockonstart:
wx.CallAfter(self.lock, force = True) wx.CallAfter(self.lock, force = True)
...@@ -282,11 +278,6 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -282,11 +278,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if self.filename: if self.filename:
self.printbtn.Enable() self.printbtn.Enable()
def layer_change_cb(self, newlayer):
if self.compute_eta:
secondselapsed = int(time.time() - self.starttime + self.extra_print_time)
self.compute_eta.update_layer(newlayer, secondselapsed)
def sentcb(self, line): def sentcb(self, line):
gline = gcoder.Line(line) gline = gcoder.Line(line)
split_raw = gcoder.split(gline) split_raw = gcoder.split(gline)
......
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