Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
c630318b
Commit
c630318b
authored
May 25, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add improved ETA computation (untested yet)
parent
7c78d539
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
8 deletions
+55
-8
printcore.py
printcore.py
+5
-0
printrun_utils.py
printrun/printrun_utils.py
+27
-0
pronterface.py
pronterface.py
+23
-8
No files found.
printcore.py
View file @
c630318b
...
@@ -62,6 +62,7 @@ class printcore():
...
@@ -62,6 +62,7 @@ class printcore():
self
.
recvcb
=
None
#impl (wholeline)
self
.
recvcb
=
None
#impl (wholeline)
self
.
sendcb
=
None
#impl (wholeline)
self
.
sendcb
=
None
#impl (wholeline)
self
.
printsendcb
=
None
#impl (wholeline)
self
.
printsendcb
=
None
#impl (wholeline)
self
.
layerchangecb
=
None
#impl (wholeline)
self
.
errorcb
=
None
#impl (wholeline)
self
.
errorcb
=
None
#impl (wholeline)
self
.
startcb
=
None
#impl ()
self
.
startcb
=
None
#impl ()
self
.
endcb
=
None
#impl ()
self
.
endcb
=
None
#impl ()
...
@@ -383,6 +384,10 @@ class printcore():
...
@@ -383,6 +384,10 @@ class printcore():
if
self
.
printing
and
self
.
queueindex
<
len
(
self
.
mainqueue
):
if
self
.
printing
and
self
.
queueindex
<
len
(
self
.
mainqueue
):
(
layer
,
line
)
=
self
.
mainqueue
.
idxs
(
self
.
queueindex
)
(
layer
,
line
)
=
self
.
mainqueue
.
idxs
(
self
.
queueindex
)
gline
=
self
.
mainqueue
.
all_layers
[
layer
]
.
lines
[
line
]
gline
=
self
.
mainqueue
.
all_layers
[
layer
]
.
lines
[
line
]
if
self
.
layerchangecb
and
self
.
queueindex
>
0
:
(
prev_layer
,
prev_line
)
=
self
.
mainqueue
.
idxs
(
self
.
queuindex
-
1
)
if
prev_layer
!=
layer
:
self
.
layerchangecb
(
layer
)
tline
=
gline
.
raw
tline
=
gline
.
raw
#check for host command
#check for host command
if
tline
.
lstrip
()
.
startswith
(
";@"
):
if
tline
.
lstrip
()
.
startswith
(
";@"
):
...
...
printrun/printrun_utils.py
View file @
c630318b
...
@@ -56,3 +56,30 @@ def sharedfile(filename):
...
@@ -56,3 +56,30 @@ def sharedfile(filename):
def
configfile
(
filename
):
def
configfile
(
filename
):
return
lookup_file
(
filename
,
[
os
.
path
.
expanduser
(
"~/.printrun/"
),])
return
lookup_file
(
filename
,
[
os
.
path
.
expanduser
(
"~/.printrun/"
),])
class
RemainingTimeEstimator
(
object
):
drift
=
None
gcode
=
None
def
__init__
(
self
,
gcode
):
self
.
drift
=
1
self
.
previous_layers_estimate
=
0
self
.
current_layer_estimate
=
0
self
.
current_layer_lines
=
0
self
.
remaining_layers_estimate
=
0
self
.
gcode
=
gcode
def
update_layer
(
self
,
layer
,
printtime
):
self
.
previous_layers_estimate
+=
self
.
current_layer_estimate
if
self
.
previous_layers_estimate
>
0
and
printtime
>
0
:
self
.
drift
=
printtime
/
self
.
previous_layers_estimate
self
.
current_layer_estimate
=
self
.
gcode
.
all_layers
[
layer
]
.
duration
self
.
current_layer_lines
=
len
(
self
.
gcode
.
all_layers
[
layer
]
.
lines
)
self
.
remaining_layers_estimate
-=
self
.
current_layer_estimate
def
__call__
(
self
,
idx
):
layer
,
line
=
self
.
gcode
.
idxs
(
idx
)
layer_progress
=
(
1
-
((
line
+
1
)
/
self
.
current_layer_lines
))
remaining
=
layer_progress
*
self
.
current_layer_estimate
+
self
.
remaining_layers_estimate
return
drift
*
remaining
pronterface.py
View file @
c630318b
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
import
os
,
Queue
,
re
import
os
,
Queue
,
re
from
printrun.printrun_utils
import
install_locale
from
printrun.printrun_utils
import
install_locale
,
RemainingTimeEstimator
install_locale
(
'pronterface'
)
install_locale
(
'pronterface'
)
try
:
try
:
...
@@ -276,8 +276,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -276,8 +276,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
mini
=
False
self
.
mini
=
False
self
.
p
.
sendcb
=
self
.
sentcb
self
.
p
.
sendcb
=
self
.
sentcb
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
.
starttime
=
0
self
.
starttime
=
0
self
.
extra_print_time
=
0
self
.
extra_print_time
=
0
self
.
curlayer
=
0
self
.
curlayer
=
0
...
@@ -306,6 +308,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -306,6 +308,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def
startcb
(
self
):
def
startcb
(
self
):
self
.
starttime
=
time
.
time
()
self
.
starttime
=
time
.
time
()
self
.
compute_eta
=
RemainingTimeEstimator
(
self
.
p
.
mainqueue
)
print
_
(
"Print Started at:
%
s"
)
%
format_time
(
self
.
starttime
)
print
_
(
"Print Started at:
%
s"
)
%
format_time
(
self
.
starttime
)
def
endcb
(
self
):
def
endcb
(
self
):
...
@@ -340,6 +343,11 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -340,6 +343,11 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
self
.
filename
:
if
self
.
filename
:
wx
.
CallAfter
(
self
.
printbtn
.
Enable
)
wx
.
CallAfter
(
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
)
gline
.
parse_coordinates
(
imperial
=
False
)
gline
.
parse_coordinates
(
imperial
=
False
)
...
@@ -1174,17 +1182,24 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1174,17 +1182,24 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
self
.
sdprinting
:
if
self
.
sdprinting
:
fractioncomplete
=
float
(
self
.
percentdone
/
100.0
)
fractioncomplete
=
float
(
self
.
percentdone
/
100.0
)
string
+=
_
(
" SD printing:
%04.2
f
%%
"
)
%
(
self
.
percentdone
,)
string
+=
_
(
" SD printing:
%04.2
f
%%
"
)
%
(
self
.
percentdone
,)
if
fractioncomplete
>
0.0
:
secondselapsed
=
int
(
time
.
time
()
-
self
.
starttime
+
self
.
extra_print_time
)
secondsestimate
=
secondselapsed
/
fractioncomplete
secondsremain
=
secondsestimate
-
secondselapsed
string
+=
_
(
" Est:
%
s of
%
s remaining | "
)
%
(
format_duration
(
secondsremain
),
format_duration
(
secondsestimate
))
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
if
self
.
p
.
printing
:
if
self
.
p
.
printing
:
fractioncomplete
=
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
)
fractioncomplete
=
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
)
string
+=
_
(
" Printing:
%04.2
f
%%
|"
)
%
(
100
*
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
),)
string
+=
_
(
" Printing:
%04.2
f
%%
|"
)
%
(
100
*
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
),)
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
if
fractioncomplete
>
0.
0
:
if
self
.
p
.
queueindex
>
0
:
secondselapsed
=
int
(
time
.
time
()
-
self
.
starttime
+
self
.
extra_print_time
)
secondselapsed
=
int
(
time
.
time
()
-
self
.
starttime
+
self
.
extra_print_time
)
secondsestimate
=
secondselapsed
/
fractioncomplete
secondsremain
=
self
.
compute_eta
(
self
.
p
.
queueindex
)
secondsremain
=
secondsestimate
-
secondselapsed
secondsestimate
=
secondselapsed
+
secondsremain
string
+=
_
(
" Est:
%
s of
%
s remaining | "
)
%
(
format_duration
(
secondsremain
),
string
+=
_
(
" Est:
%
s of
%
s remaining | "
)
%
(
format_duration
(
secondsremain
),
format_duration
(
secondsestimate
))
format_duration
(
secondsestimate
))
string
+=
_
(
" Z:
%0.2
f mm"
)
%
self
.
curlayer
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
wx
.
CallAfter
(
self
.
status
.
SetStatusText
,
string
)
wx
.
CallAfter
(
self
.
status
.
SetStatusText
,
string
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
if
(
self
.
monitor
and
self
.
p
.
online
):
if
(
self
.
monitor
and
self
.
p
.
online
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment