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
6cce62b2
Commit
6cce62b2
authored
Jun 02, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:kliment/Printrun
parents
16934b24
598d39e2
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
488 additions
and
447 deletions
+488
-447
pronsole.py
printrun/pronsole.py
+77
-354
pronterface.py
printrun/pronterface.py
+47
-93
settings.py
printrun/settings.py
+361
-0
utils.py
printrun/utils.py
+3
-0
No files found.
printrun/pronsole.py
View file @
6cce62b2
This diff is collapsed.
Click to expand it.
printrun/pronterface.py
View file @
6cce62b2
...
...
@@ -33,7 +33,7 @@ except ImportError: import json
from
.
import
pronsole
from
.
import
printcore
from
.utils
import
install_locale
,
setup_logging
,
\
from
.utils
import
install_locale
,
setup_logging
,
dosify
,
\
iconfile
,
configfile
,
format_time
,
format_duration
,
\
hexcolor_to_float
,
parse_temperature_report
,
\
prepare_command
,
check_rgb_color
,
check_rgba_color
...
...
@@ -45,8 +45,7 @@ except:
logging
.
error
(
_
(
"WX is not installed. This program requires WX to run."
))
raise
from
printrun.gui.widgets
import
SpecialButton
,
MacroEditor
,
\
PronterOptions
,
ButtonEdit
from
.gui.widgets
import
SpecialButton
,
MacroEditor
,
PronterOptions
,
ButtonEdit
winsize
=
(
800
,
500
)
layerindex
=
0
...
...
@@ -58,12 +57,12 @@ pronterface_quitting = False
class
PronterfaceQuitException
(
Exception
):
pass
from
printrun.gui
import
MainWindow
from
printrun.excluder
import
Excluder
from
pronsole
import
dosify
,
wxSetting
,
HiddenSetting
,
StringSetting
,
SpinSetting
,
FloatSpinSetting
,
BooleanSetting
,
StaticTextSetting
from
.gui
import
MainWindow
from
.excluder
import
Excluder
from
.settings
import
wxSetting
,
HiddenSetting
,
StringSetting
,
SpinSetting
,
\
FloatSpinSetting
,
BooleanSetting
,
StaticTextSetting
from
printrun
import
gcoder
tempreading_exp
=
re
.
compile
(
"(^T:| T:)"
)
from
.pronsole
import
REPORT_NONE
,
REPORT_POS
,
REPORT_TEMP
class
Tee
(
object
):
def
__init__
(
self
,
target
):
...
...
@@ -141,14 +140,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
filename
=
filename
self
.
statuscheck
=
False
self
.
status_thread
=
None
self
.
capture_skip
=
{}
self
.
capture_skip_newline
=
False
self
.
tempreadings
=
""
self
.
userm114
=
0
self
.
userm105
=
0
self
.
m105_waitcycles
=
0
self
.
fgcode
=
None
self
.
excluder
=
None
self
.
slicep
=
None
...
...
@@ -327,10 +320,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
pronsole
.
pronsole
.
kill
(
self
)
global
pronterface_quitting
pronterface_quitting
=
True
self
.
statuscheck
=
False
if
self
.
status_thread
:
self
.
status_thread
.
join
()
self
.
status_thread
=
None
self
.
p
.
recvcb
=
None
self
.
p
.
disconnect
()
if
hasattr
(
self
,
"feedrates_changed"
):
...
...
@@ -969,54 +958,30 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
# Statusbar handling
# --------------------------------------------------------------
def
statuschecker
(
self
):
while
self
.
statuscheck
:
string
=
""
def
statuschecker_inner
(
self
):
status_string
=
""
if
self
.
sdprinting
or
self
.
uploading
or
self
.
p
.
printing
:
secondsremain
,
secondsestimate
,
progress
=
self
.
get_eta
()
if
self
.
sdprinting
or
self
.
uploading
:
if
self
.
uploading
:
string
+=
_
(
"SD upload:
%04.2
f
%%
|"
)
%
(
100
*
progress
,)
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
status_
string
+=
_
(
"SD upload:
%04.2
f
%%
|"
)
%
(
100
*
progress
,)
status_
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
else
:
string
+=
_
(
"SD printing:
%04.2
f
%%
|"
)
%
(
self
.
percentdone
,)
status_
string
+=
_
(
"SD printing:
%04.2
f
%%
|"
)
%
(
self
.
percentdone
,)
elif
self
.
p
.
printing
:
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
))
status_
string
+=
_
(
"Printing:
%04.2
f
%%
|"
)
%
(
100
*
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
),)
status_
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
if
progress
>
0
:
string
+=
_
(
" Est:
%
s of
%
s remaining | "
)
%
(
format_duration
(
secondsremain
),
status_
string
+=
_
(
" Est:
%
s of
%
s remaining | "
)
%
(
format_duration
(
secondsremain
),
format_duration
(
secondsestimate
))
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
status_
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
elif
self
.
loading_gcode
:
string
=
self
.
loading_gcode_message
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
string
)
status_
string
=
self
.
loading_gcode_message
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
status_
string
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
if
self
.
p
.
online
:
if
self
.
p
.
writefailures
>=
4
:
self
.
logError
(
_
(
"Disconnecting after 4 failed writes."
))
self
.
status_thread
=
None
self
.
disconnect
()
return
if
self
.
settings
.
monitor
and
self
.
p
.
online
:
if
self
.
sdprinting
:
self
.
p
.
send_now
(
"M27"
)
if
self
.
m105_waitcycles
%
10
==
0
:
self
.
p
.
send_now
(
"M105"
)
self
.
m105_waitcycles
+=
1
cur_time
=
time
.
time
()
wait_time
=
0
while
time
.
time
()
<
cur_time
+
self
.
monitor_interval
-
0.25
:
if
not
self
.
statuscheck
:
break
time
.
sleep
(
0.25
)
# Safeguard: if system time changes and goes back in the past,
# we could get stuck almost forever
wait_time
+=
0.25
if
wait_time
>
self
.
monitor_interval
-
0.25
:
break
# Always sleep at least a bit, if something goes wrong with the
# system time we'll avoid freezing the whole app this way
time
.
sleep
(
0.25
)
# Call pronsole's statuschecker inner loop function to handle
# temperature monitoring and status loop sleep
pronsole
.
pronsole
.
statuschecker_inner
(
self
,
self
.
settings
.
monitor
)
try
:
while
not
self
.
sentlines
.
empty
():
gc
=
self
.
sentlines
.
get_nowait
()
...
...
@@ -1024,6 +989,9 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
sentlines
.
task_done
()
except
Queue
.
Empty
:
pass
def
statuschecker
(
self
):
pronsole
.
pronsole
.
statuschecker
(
self
)
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
_
(
"Not connected to printer."
))
# --------------------------------------------------------------
...
...
@@ -1072,13 +1040,10 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
p
.
send_now
(
"M26 S0"
)
if
not
self
.
connect_to_printer
(
port
,
baud
):
return
self
.
statuscheck
=
True
if
port
!=
self
.
settings
.
port
:
self
.
set
(
"port"
,
port
)
if
baud
!=
self
.
settings
.
baudrate
:
self
.
set
(
"baudrate"
,
str
(
baud
))
self
.
status_thread
=
threading
.
Thread
(
target
=
self
.
statuschecker
)
self
.
status_thread
.
start
()
if
self
.
predisconnect_mainqueue
:
self
.
recoverbtn
.
Enable
()
...
...
@@ -1675,8 +1640,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
except
:
traceback
.
print_exc
()
def
update_pos
(
self
,
l
):
bits
=
gcoder
.
m114_exp
.
findall
(
l
)
def
update_pos
(
self
):
bits
=
gcoder
.
m114_exp
.
findall
(
self
.
posreport
)
x
=
None
y
=
None
z
=
None
...
...
@@ -1693,24 +1658,13 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if
z
is
not
None
:
self
.
current_pos
[
2
]
=
z
def
recvcb
(
self
,
l
):
isreport
=
False
if
"ok C:"
in
l
or
"Count"
in
l
\
or
(
"X:"
in
l
and
len
(
gcoder
.
m114_exp
.
findall
(
l
))
==
6
):
self
.
posreport
=
l
self
.
update_pos
(
l
)
if
self
.
userm114
>
0
:
self
.
userm114
-=
1
else
:
isreport
=
True
if
"ok T:"
in
l
or
tempreading_exp
.
findall
(
l
):
self
.
tempreadings
=
l
report_type
=
self
.
recvcb_report
(
l
)
isreport
=
report_type
!=
REPORT_NONE
if
report_type
==
REPORT_POS
:
self
.
update_pos
()
elif
report_type
==
REPORT_TEMP
:
wx
.
CallAfter
(
self
.
tempdisp
.
SetLabel
,
self
.
tempreadings
.
strip
()
.
replace
(
"ok "
,
""
))
self
.
update_tempdisplay
()
if
self
.
userm105
>
0
:
self
.
userm105
-=
1
else
:
self
.
m105_waitcycles
=
0
isreport
=
True
tstring
=
l
.
rstrip
()
if
not
self
.
p
.
loud
and
(
tstring
not
in
[
"ok"
,
"wait"
]
and
not
isreport
):
wx
.
CallAfter
(
self
.
addtexttolog
,
tstring
+
"
\n
"
)
...
...
printrun/settings.py
0 → 100644
View file @
6cce62b2
This diff is collapsed.
Click to expand it.
printrun/utils.py
View file @
6cce62b2
...
...
@@ -117,6 +117,9 @@ def get_command_output(command, replaces):
blocking
=
False
)
return
p
.
stdout
.
read
()
def
dosify
(
name
):
return
os
.
path
.
split
(
name
)[
1
]
.
split
(
"."
)[
0
][:
8
]
+
".g"
class
RemainingTimeEstimator
(
object
):
drift
=
None
...
...
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