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
...
@@ -33,7 +33,7 @@ except ImportError: import json
from
.
import
pronsole
from
.
import
pronsole
from
.
import
printcore
from
.
import
printcore
from
.utils
import
install_locale
,
setup_logging
,
\
from
.utils
import
install_locale
,
setup_logging
,
dosify
,
\
iconfile
,
configfile
,
format_time
,
format_duration
,
\
iconfile
,
configfile
,
format_time
,
format_duration
,
\
hexcolor_to_float
,
parse_temperature_report
,
\
hexcolor_to_float
,
parse_temperature_report
,
\
prepare_command
,
check_rgb_color
,
check_rgba_color
prepare_command
,
check_rgb_color
,
check_rgba_color
...
@@ -45,8 +45,7 @@ except:
...
@@ -45,8 +45,7 @@ except:
logging
.
error
(
_
(
"WX is not installed. This program requires WX to run."
))
logging
.
error
(
_
(
"WX is not installed. This program requires WX to run."
))
raise
raise
from
printrun.gui.widgets
import
SpecialButton
,
MacroEditor
,
\
from
.gui.widgets
import
SpecialButton
,
MacroEditor
,
PronterOptions
,
ButtonEdit
PronterOptions
,
ButtonEdit
winsize
=
(
800
,
500
)
winsize
=
(
800
,
500
)
layerindex
=
0
layerindex
=
0
...
@@ -58,12 +57,12 @@ pronterface_quitting = False
...
@@ -58,12 +57,12 @@ pronterface_quitting = False
class
PronterfaceQuitException
(
Exception
):
class
PronterfaceQuitException
(
Exception
):
pass
pass
from
printrun.gui
import
MainWindow
from
.gui
import
MainWindow
from
printrun.excluder
import
Excluder
from
.excluder
import
Excluder
from
pronsole
import
dosify
,
wxSetting
,
HiddenSetting
,
StringSetting
,
SpinSetting
,
FloatSpinSetting
,
BooleanSetting
,
StaticTextSetting
from
.settings
import
wxSetting
,
HiddenSetting
,
StringSetting
,
SpinSetting
,
\
FloatSpinSetting
,
BooleanSetting
,
StaticTextSetting
from
printrun
import
gcoder
from
printrun
import
gcoder
from
.pronsole
import
REPORT_NONE
,
REPORT_POS
,
REPORT_TEMP
tempreading_exp
=
re
.
compile
(
"(^T:| T:)"
)
class
Tee
(
object
):
class
Tee
(
object
):
def
__init__
(
self
,
target
):
def
__init__
(
self
,
target
):
...
@@ -141,14 +140,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -141,14 +140,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
filename
=
filename
self
.
filename
=
filename
self
.
statuscheck
=
False
self
.
status_thread
=
None
self
.
capture_skip
=
{}
self
.
capture_skip
=
{}
self
.
capture_skip_newline
=
False
self
.
capture_skip_newline
=
False
self
.
tempreadings
=
""
self
.
userm114
=
0
self
.
userm105
=
0
self
.
m105_waitcycles
=
0
self
.
fgcode
=
None
self
.
fgcode
=
None
self
.
excluder
=
None
self
.
excluder
=
None
self
.
slicep
=
None
self
.
slicep
=
None
...
@@ -327,10 +320,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -327,10 +320,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
pronsole
.
pronsole
.
kill
(
self
)
pronsole
.
pronsole
.
kill
(
self
)
global
pronterface_quitting
global
pronterface_quitting
pronterface_quitting
=
True
pronterface_quitting
=
True
self
.
statuscheck
=
False
if
self
.
status_thread
:
self
.
status_thread
.
join
()
self
.
status_thread
=
None
self
.
p
.
recvcb
=
None
self
.
p
.
recvcb
=
None
self
.
p
.
disconnect
()
self
.
p
.
disconnect
()
if
hasattr
(
self
,
"feedrates_changed"
):
if
hasattr
(
self
,
"feedrates_changed"
):
...
@@ -969,54 +958,30 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -969,54 +958,30 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
# Statusbar handling
# Statusbar handling
# --------------------------------------------------------------
# --------------------------------------------------------------
def
statuschecker
(
self
):
def
statuschecker_inner
(
self
):
while
self
.
statuscheck
:
status_string
=
""
string
=
""
if
self
.
sdprinting
or
self
.
uploading
or
self
.
p
.
printing
:
if
self
.
sdprinting
or
self
.
uploading
or
self
.
p
.
printing
:
secondsremain
,
secondsestimate
,
progress
=
self
.
get_eta
()
secondsremain
,
secondsestimate
,
progress
=
self
.
get_eta
()
if
self
.
sdprinting
or
self
.
uploading
:
if
self
.
sdprinting
or
self
.
uploading
:
if
self
.
uploading
:
if
self
.
uploading
:
string
+=
_
(
"SD upload:
%04.2
f
%%
|"
)
%
(
100
*
progress
,)
status_
string
+=
_
(
"SD upload:
%04.2
f
%%
|"
)
%
(
100
*
progress
,)
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
status_
string
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
else
:
else
:
string
+=
_
(
"SD printing:
%04.2
f
%%
|"
)
%
(
self
.
percentdone
,)
status_
string
+=
_
(
"SD printing:
%04.2
f
%%
|"
)
%
(
self
.
percentdone
,)
elif
self
.
p
.
printing
:
elif
self
.
p
.
printing
:
string
+=
_
(
"Printing:
%04.2
f
%%
|"
)
%
(
100
*
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
),)
status_
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
+=
_
(
" Line#
%
d of
%
d lines |"
)
%
(
self
.
p
.
queueindex
,
len
(
self
.
p
.
mainqueue
))
if
progress
>
0
:
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
))
format_duration
(
secondsestimate
))
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
status_
string
+=
_
(
" Z:
%.3
f mm"
)
%
self
.
curlayer
elif
self
.
loading_gcode
:
elif
self
.
loading_gcode
:
string
=
self
.
loading_gcode_message
status_
string
=
self
.
loading_gcode_message
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
string
)
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
status_
string
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
wx
.
CallAfter
(
self
.
gviz
.
Refresh
)
if
self
.
p
.
online
:
# Call pronsole's statuschecker inner loop function to handle
if
self
.
p
.
writefailures
>=
4
:
# temperature monitoring and status loop sleep
self
.
logError
(
_
(
"Disconnecting after 4 failed writes."
))
pronsole
.
pronsole
.
statuschecker_inner
(
self
,
self
.
settings
.
monitor
)
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
)
try
:
try
:
while
not
self
.
sentlines
.
empty
():
while
not
self
.
sentlines
.
empty
():
gc
=
self
.
sentlines
.
get_nowait
()
gc
=
self
.
sentlines
.
get_nowait
()
...
@@ -1024,6 +989,9 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -1024,6 +989,9 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
sentlines
.
task_done
()
self
.
sentlines
.
task_done
()
except
Queue
.
Empty
:
except
Queue
.
Empty
:
pass
pass
def
statuschecker
(
self
):
pronsole
.
pronsole
.
statuschecker
(
self
)
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
_
(
"Not connected to printer."
))
wx
.
CallAfter
(
self
.
statusbar
.
SetStatusText
,
_
(
"Not connected to printer."
))
# --------------------------------------------------------------
# --------------------------------------------------------------
...
@@ -1072,13 +1040,10 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -1072,13 +1040,10 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
p
.
send_now
(
"M26 S0"
)
self
.
p
.
send_now
(
"M26 S0"
)
if
not
self
.
connect_to_printer
(
port
,
baud
):
if
not
self
.
connect_to_printer
(
port
,
baud
):
return
return
self
.
statuscheck
=
True
if
port
!=
self
.
settings
.
port
:
if
port
!=
self
.
settings
.
port
:
self
.
set
(
"port"
,
port
)
self
.
set
(
"port"
,
port
)
if
baud
!=
self
.
settings
.
baudrate
:
if
baud
!=
self
.
settings
.
baudrate
:
self
.
set
(
"baudrate"
,
str
(
baud
))
self
.
set
(
"baudrate"
,
str
(
baud
))
self
.
status_thread
=
threading
.
Thread
(
target
=
self
.
statuschecker
)
self
.
status_thread
.
start
()
if
self
.
predisconnect_mainqueue
:
if
self
.
predisconnect_mainqueue
:
self
.
recoverbtn
.
Enable
()
self
.
recoverbtn
.
Enable
()
...
@@ -1675,8 +1640,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -1675,8 +1640,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
except
:
except
:
traceback
.
print_exc
()
traceback
.
print_exc
()
def
update_pos
(
self
,
l
):
def
update_pos
(
self
):
bits
=
gcoder
.
m114_exp
.
findall
(
l
)
bits
=
gcoder
.
m114_exp
.
findall
(
self
.
posreport
)
x
=
None
x
=
None
y
=
None
y
=
None
z
=
None
z
=
None
...
@@ -1693,24 +1658,13 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
...
@@ -1693,24 +1658,13 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if
z
is
not
None
:
self
.
current_pos
[
2
]
=
z
if
z
is
not
None
:
self
.
current_pos
[
2
]
=
z
def
recvcb
(
self
,
l
):
def
recvcb
(
self
,
l
):
isreport
=
False
report_type
=
self
.
recvcb_report
(
l
)
if
"ok C:"
in
l
or
"Count"
in
l
\
isreport
=
report_type
!=
REPORT_NONE
or
(
"X:"
in
l
and
len
(
gcoder
.
m114_exp
.
findall
(
l
))
==
6
):
if
report_type
==
REPORT_POS
:
self
.
posreport
=
l
self
.
update_pos
()
self
.
update_pos
(
l
)
elif
report_type
==
REPORT_TEMP
:
if
self
.
userm114
>
0
:
self
.
userm114
-=
1
else
:
isreport
=
True
if
"ok T:"
in
l
or
tempreading_exp
.
findall
(
l
):
self
.
tempreadings
=
l
wx
.
CallAfter
(
self
.
tempdisp
.
SetLabel
,
self
.
tempreadings
.
strip
()
.
replace
(
"ok "
,
""
))
wx
.
CallAfter
(
self
.
tempdisp
.
SetLabel
,
self
.
tempreadings
.
strip
()
.
replace
(
"ok "
,
""
))
self
.
update_tempdisplay
()
self
.
update_tempdisplay
()
if
self
.
userm105
>
0
:
self
.
userm105
-=
1
else
:
self
.
m105_waitcycles
=
0
isreport
=
True
tstring
=
l
.
rstrip
()
tstring
=
l
.
rstrip
()
if
not
self
.
p
.
loud
and
(
tstring
not
in
[
"ok"
,
"wait"
]
and
not
isreport
):
if
not
self
.
p
.
loud
and
(
tstring
not
in
[
"ok"
,
"wait"
]
and
not
isreport
):
wx
.
CallAfter
(
self
.
addtexttolog
,
tstring
+
"
\n
"
)
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):
...
@@ -117,6 +117,9 @@ def get_command_output(command, replaces):
blocking
=
False
)
blocking
=
False
)
return
p
.
stdout
.
read
()
return
p
.
stdout
.
read
()
def
dosify
(
name
):
return
os
.
path
.
split
(
name
)[
1
]
.
split
(
"."
)[
0
][:
8
]
+
".g"
class
RemainingTimeEstimator
(
object
):
class
RemainingTimeEstimator
(
object
):
drift
=
None
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