From 33610d53fbfffeba6d4b335ac0bbccf022262f69 Mon Sep 17 00:00:00 2001 From: Christopher Keller Date: Mon, 28 Nov 2011 20:24:18 -0800 Subject: [PATCH 1/3] Improved status line estimated time remaining. uses format: SD Printing: pp.p% | Est: hh:mm:ss of hh:mm:ss of hh:mm:ss remaining Printing: pp.p% | @ Line# xxx of yyyyy lines | Est: hh:mm:ss of hh:mm:ss remaining --- pronterface.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pronterface.py b/pronterface.py index ef30bb6..31e57e5 100755 --- a/pronterface.py +++ b/pronterface.py @@ -1085,18 +1085,25 @@ class PronterWindow(wx.Frame,pronsole.pronsole): # self.tgauge.SetValue(int(filter(lambda x:x.startswith("T:"),self.tempreport.split())[0].split(":")[1])) #except: # pass + fractioncomplete = 0.0 if self.sdprinting: + fractioncomplete = float(self.percentdone/100.0) string+= _(" SD printing:%04.2f %%") % (self.percentdone,) if self.p.printing: - secondselapsed = int(time.time()-self.starttime) fractioncomplete = float(self.p.queueindex)/len(self.p.mainqueue) + string+= _(" Printing:%04.2f %% |") % (100*float(self.p.queueindex)/len(self.p.mainqueue),) + string+= _(" Line# ") + str(self.p.queueindex) + _("of ") + str(len(self.p.mainqueue)) + _(" lines |" ) + if fractioncomplete > 0.0: + secondselapsed = int(time.time()-self.starttime) secondsestimate = secondselapsed/fractioncomplete secondsremain = secondsestimate - secondselapsed - string+= _(" Printing:%04.2f %%") % (100*float(self.p.queueindex)/len(self.p.mainqueue),) - string+= _(" Estimated:%02.0f") % (int(secondsremain/60),) - string+= _(":%02.0f") % (int(secondsremain%60),) - string+= _(" of %02.0f") % (int(secondsestimate/60),) - string+= _(":%02.0f Remaining") % (int(secondsestimate%60),) + string+= _(" Est: ") + time.strftime('%H:%M:%S', time.gmtime(secondsremain)) + string+= _(" of: ") + time.strftime('%H:%M:%S', time.gmtime(secondsestimate)) + string+= _(" Remaining") + #string+= _(" Est:%02.0f") % (int(secondsremain/60),) + #string+= _(":%02.0f") % (int(secondsremain%60),) + #string+= _(" of %02.0f") % (int(secondsestimate/60),) + #string+= _(":%02.0f Remaining") % (int(secondsestimate%60),) wx.CallAfter(self.status.SetStatusText,string) wx.CallAfter(self.gviz.Refresh) if(self.monitor and self.p.online): From cc40719e6c9f336880e338f6c521424fcb4abc9d Mon Sep 17 00:00:00 2001 From: Christopher Keller Date: Mon, 28 Nov 2011 20:36:04 -0800 Subject: [PATCH 2/3] Fixed the time estimator in pronsole.py at beginning of move set feedrate to average of last and current feedrate. do move with that feedrate. then set the feedrate to the current feedrate. if it's just a feedrate change, then the feedrate will become the feedrate. if there is no feedrate in current move, feedrate will be last feedrate if there is a move and a new feedrate then the move will take however long the average feedrate would take. estimation is a bit more optimistic than pessimistic. however it seems to be a lot more accurate. --- pronsole.py | 93 +++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/pronsole.py b/pronsole.py index 1be8371..c5d29e9 100755 --- a/pronsole.py +++ b/pronsole.py @@ -89,53 +89,56 @@ def get_coordinate_value(axis, parts): def estimate_duration(g): - extra_cost_per_movement = 0.02 - total_duration = 0 - feedrate = 0 - X_last_position = 0 - Y_last_position = 0 - for i in g: - i=i.split(";")[0] - if "G1" in i and ("X" in i or "Y" in i or "F" in i or "E" in i): - parts = i.split(" ") - X = get_coordinate_value("X", parts[1:]) - Y = get_coordinate_value("Y", parts[1:]) - F = get_coordinate_value("F", parts[1:]) - E = get_coordinate_value("E", parts[1:]) + extra_cost_per_movement = 0.02 + total_duration = 0.0 + feedrate = 0.0 + avg_feedrate = 0.0 + last_feedrate = 0.0 + X_last_position = 0.0 + Y_last_position = 0.0 + Z_last_position = 0.0 + for i in g: + i=i.split(";")[0] + if "G1" in i and ("X" in i or "Y" in i or "F" in i or "E" in i): + #if "G1" in i and ("X" in i or "Y" in i or "Z" in i or "F" in i or "E" in i): + parts = i.split(" ") + X = get_coordinate_value("X", parts[1:]) + Y = get_coordinate_value("Y", parts[1:]) + #Z = get_coordinate_value("Z", parts[1:]) + F = get_coordinate_value("F", parts[1:]) + E = get_coordinate_value("E", parts[1:]) - if (F is not None): - feedrate = F / 60 - - distance = 0 - if (X is None and Y is None and E is not None): - distance = abs(E) - elif (X is not None and Y is None): - distance = X - X_last_position - X_last_position = X - elif (X is None and Y is not None): - distance = Y - Y_last_position - Y_last_position = Y - elif (X is not None and Y is not None): - X_distance = X - X_last_position - Y_distance = Y - Y_last_position - distance = sqrt(X_distance * X_distance + Y_distance * Y_distance) - X_last_position = X - Y_last_position = Y + if (F is not None): + feedrate = (last_feedrate + (F / 60.0))/2.0 + distance = 0 + if (X is None and Y is None and E is not None): + distance = abs(E) + elif (X is not None and Y is None): + distance = X - X_last_position + X_last_position = X + elif (X is None and Y is not None): + distance = Y - Y_last_position + Y_last_position = Y + elif (X is not None and Y is not None): + X_distance = X - X_last_position + Y_distance = Y - Y_last_position + distance = sqrt(X_distance * X_distance + Y_distance * Y_distance) + X_last_position = X + Y_last_position = Y + #if (Z is not None): + # Z_distance = Z - Z_last_position + # if not(distance == 0.0): + # distance = sqrt(Z_distance * Z_distance + distance * distance ) + # else: + # distance = Z_distance + # Z_last_position = Z - if (feedrate == 0 or distance == 0): continue - - time_for_move = distance / feedrate - acceleration = feedrate / time_for_move - halfway_feedrate = acceleration * time_for_move / 2 - duration = halfway_feedrate * 2 / acceleration - - total_duration += duration + extra_cost_per_movement - - mod_minutes = total_duration % (60 * 60) - mod_seconds = mod_minutes % 60 - - return "{0:02d}h{1:02d}m".format(int((total_duration - mod_minutes) / (60 * 60)), int((mod_minutes - mod_seconds) / 60)) - + if (feedrate == 0.0 or distance == 0.0): continue + + time_for_move = distance / feedrate + total_duration += time_for_move + extra_cost_per_movement + if (F is not None): feedrate = F / 60.0 + return time.strftime('%H:%M:%S', time.gmtime(total_duration/60.0)) class Settings: #def _temperature_alias(self): return {"pla":210,"abs":230,"off":0} #def _temperature_validate(self,v): From 225d61651c91a27918fcfe1c85d0a3509beb8bbd Mon Sep 17 00:00:00 2001 From: Christopher Keller Date: Tue, 29 Nov 2011 14:37:34 -0800 Subject: [PATCH 3/3] Added Current Z-Height to the status message. Also added "Print Began at: HH:MM:SS" and added the message "Print Ended at: HH:MM:SS: and took... --- pronterface.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pronterface.py b/pronterface.py index 31e57e5..b38b79f 100755 --- a/pronterface.py +++ b/pronterface.py @@ -122,10 +122,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole): def startcb(self): self.starttime=time.time() + print "Print Started at: " +time.strftime('%H:%M:%S',time.localtime(self.starttime)) def endcb(self): if(self.p.queueindex==0): - print "Print took "+str(int(time.time()-self.starttime)/60)+" minutes "+str(int(time.time()-self.starttime)%60)+" seconds." + print "Print ended at: " +time.strftime('%H:%M:%S',time.localtime(time.time())) + print "and took: "+time.strftime('%H:%M:%S', time.gmtime(int(time.time()-self.starttime))) #+str(int(time.time()-self.starttime)/60)+" minutes "+str(int(time.time()-self.starttime)%60)+" seconds." wx.CallAfter(self.pausebtn.Disable) wx.CallAfter(self.printbtn.SetLabel,_("Print")) @@ -1099,11 +1101,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): secondsremain = secondsestimate - secondselapsed string+= _(" Est: ") + time.strftime('%H:%M:%S', time.gmtime(secondsremain)) string+= _(" of: ") + time.strftime('%H:%M:%S', time.gmtime(secondsestimate)) - string+= _(" Remaining") - #string+= _(" Est:%02.0f") % (int(secondsremain/60),) - #string+= _(":%02.0f") % (int(secondsremain%60),) - #string+= _(" of %02.0f") % (int(secondsestimate/60),) - #string+= _(":%02.0f Remaining") % (int(secondsestimate%60),) + string+= _(" Remaining | ") + string+= _(" Z: %0.2f mm") % self.curlayer wx.CallAfter(self.status.SetStatusText,string) wx.CallAfter(self.gviz.Refresh) if(self.monitor and self.p.online):