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
360b4f60
Commit
360b4f60
authored
Apr 07, 2013
by
fsantini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pause code working;
implemented the @pause gcode host command (and a small framework for host commands)
parent
00f1306f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
27 deletions
+85
-27
GCodeAnalyzer.py
GCodeAnalyzer.py
+1
-0
gcoder.py
gcoder.py
+4
-0
printcore.py
printcore.py
+53
-15
pronterface.py
pronterface.py
+27
-12
No files found.
GCodeAnalyzer.py
View file @
360b4f60
...
@@ -76,6 +76,7 @@ class GCodeAnalyzer():
...
@@ -76,6 +76,7 @@ class GCodeAnalyzer():
return
m
.
group
(
1
)
return
m
.
group
(
1
)
def
Analyze
(
self
,
gcode
):
def
Analyze
(
self
,
gcode
):
gcode
=
gcode
[:
gcode
.
find
(
";"
)]
# remove comments
code_g
=
self
.
findCode
(
gcode
,
"G"
)
code_g
=
self
.
findCode
(
gcode
,
"G"
)
code_m
=
self
.
findCode
(
gcode
,
"M"
)
code_m
=
self
.
findCode
(
gcode
,
"M"
)
# we have a g_code
# we have a g_code
...
...
gcoder.py
View file @
360b4f60
...
@@ -30,6 +30,10 @@ class Line(object):
...
@@ -30,6 +30,10 @@ class Line(object):
self
.
imperial
=
False
self
.
imperial
=
False
self
.
relative
=
False
self
.
relative
=
False
#ignore host commands
if
"@"
in
self
.
raw
:
self
.
raw
=
""
if
";"
in
self
.
raw
:
if
";"
in
self
.
raw
:
self
.
raw
=
self
.
raw
.
split
(
";"
)[
0
]
self
.
raw
=
self
.
raw
.
split
(
";"
)[
0
]
...
...
printcore.py
View file @
360b4f60
...
@@ -73,6 +73,7 @@ class printcore():
...
@@ -73,6 +73,7 @@ class printcore():
self
.
analyzer
=
GCodeAnalyzer
()
self
.
analyzer
=
GCodeAnalyzer
()
self
.
xy_feedrate
=
None
self
.
xy_feedrate
=
None
self
.
z_feedrate
=
None
self
.
z_feedrate
=
None
self
.
pronterface
=
None
def
disconnect
(
self
):
def
disconnect
(
self
):
"""Disconnects from printer and pauses the print
"""Disconnects from printer and pauses the print
...
@@ -223,23 +224,45 @@ class printcore():
...
@@ -223,23 +224,45 @@ class printcore():
self
.
print_thread
.
start
()
self
.
print_thread
.
start
()
return
True
return
True
# run a simple script if it exists, no multithreading
def
runSmallScript
(
self
,
filename
):
if
filename
==
None
:
return
f
=
None
try
:
f
=
open
(
filename
)
except
:
pass
if
f
!=
None
:
for
i
in
f
:
l
=
i
.
replace
(
"
\n
"
,
""
)
l
=
l
[:
l
.
find
(
";"
)]
#remove comment
self
.
send_now
(
l
)
f
.
close
()
def
pause
(
self
):
def
pause
(
self
):
"""Pauses the print, saving the current position.
"""Pauses the print, saving the current position.
"""
"""
self
.
paused
=
True
self
.
paused
=
True
self
.
printing
=
False
self
.
printing
=
False
self
.
print_thread
.
join
()
# try joining the print thread: enclose it in try/except because we might be calling it from the thread itself
try
:
self
.
print_thread
.
join
()
except
:
pass
self
.
print_thread
=
None
self
.
print_thread
=
None
# saves the status
# saves the status
self
.
pauseX
=
analyzer
.
x
-
analyzer
.
xOffset
;
self
.
pauseX
=
self
.
analyzer
.
x
-
self
.
analyzer
.
xOffset
;
self
.
pauseY
=
analyzer
.
y
-
analyzer
.
yOffset
;
self
.
pauseY
=
self
.
analyzer
.
y
-
self
.
analyzer
.
yOffset
;
self
.
pauseZ
=
analyzer
.
z
-
analyzer
.
zOffset
;
self
.
pauseZ
=
self
.
analyzer
.
z
-
self
.
analyzer
.
zOffset
;
self
.
pauseE
=
analyzer
.
e
-
analyzer
.
eOffset
;
self
.
pauseE
=
self
.
analyzer
.
e
-
self
.
analyzer
.
eOffset
;
self
.
pauseF
=
analyzer
.
f
;
self
.
pauseF
=
self
.
analyzer
.
f
;
self
.
pauseRelative
=
analyzer
.
relative
;
self
.
pauseRelative
=
self
.
analyzer
.
relative
;
def
resume
(
self
):
def
resume
(
self
):
"""Resumes a paused print.
"""Resumes a paused print.
...
@@ -247,20 +270,20 @@ class printcore():
...
@@ -247,20 +270,20 @@ class printcore():
if
self
.
paused
:
if
self
.
paused
:
#restores the status
#restores the status
self
.
send
(
"G90"
)
# go to absolute coordinates
self
.
send
_now
(
"G90"
)
# go to absolute coordinates
xyFeedString
=
""
xyFeedString
=
""
zFeedString
=
""
zFeedString
=
""
if
self
.
xy_feedrate
!=
None
:
xyFeedString
=
" F"
+
str
(
self
.
xy_feedrate
)
if
self
.
xy_feedrate
!=
None
:
xyFeedString
=
" F"
+
str
(
self
.
xy_feedrate
)
if
self
.
z_feedrate
!=
None
:
zFeedString
=
" F"
+
str
(
self
.
z_feedrate
)
if
self
.
z_feedrate
!=
None
:
zFeedString
=
" F"
+
str
(
self
.
z_feedrate
)
self
.
send
(
"G1 X"
+
str
(
self
.
pauseX
)
+
" Y"
+
str
(
self
.
pauseY
)
+
xyFeedString
)
self
.
send
_now
(
"G1 X"
+
str
(
self
.
pauseX
)
+
" Y"
+
str
(
self
.
pauseY
)
+
xyFeedString
)
self
.
send
(
"G1 Z"
+
str
(
self
.
pauseZ
)
+
zFeedString
)
self
.
send
_now
(
"G1 Z"
+
str
(
self
.
pauseZ
)
+
zFeedString
)
self
.
send
(
"G92 E"
+
str
(
self
.
pauseE
))
self
.
send
_now
(
"G92 E"
+
str
(
self
.
pauseE
))
if
self
.
pauseRelative
:
self
.
send
(
"G91"
)
# go back to relative if needed
if
self
.
pauseRelative
:
self
.
send
_now
(
"G91"
)
# go back to relative if needed
#reset old feed rate
#reset old feed rate
self
.
send
(
"G1 F"
+
str
(
self
.
pauseF
))
self
.
send
_now
(
"G1 F"
+
str
(
self
.
pauseF
))
self
.
paused
=
False
self
.
paused
=
False
self
.
printing
=
True
self
.
printing
=
True
...
@@ -324,6 +347,14 @@ class printcore():
...
@@ -324,6 +347,14 @@ class printcore():
try
:
self
.
endcb
()
try
:
self
.
endcb
()
except
:
pass
except
:
pass
#now only "pause" is implemented as host command
def
processHostCommand
(
self
,
command
):
if
command
==
"@pause"
:
if
self
.
pronterface
!=
None
:
self
.
pronterface
.
pause
(
None
)
else
:
self
.
pause
()
def
_sendnext
(
self
):
def
_sendnext
(
self
):
if
not
self
.
printer
:
if
not
self
.
printer
:
return
return
...
@@ -344,6 +375,13 @@ class printcore():
...
@@ -344,6 +375,13 @@ class printcore():
return
return
if
self
.
printing
and
self
.
queueindex
<
len
(
self
.
mainqueue
):
if
self
.
printing
and
self
.
queueindex
<
len
(
self
.
mainqueue
):
tline
=
self
.
mainqueue
[
self
.
queueindex
]
tline
=
self
.
mainqueue
[
self
.
queueindex
]
#check for host command
if
tline
.
startswith
(
"@"
):
#it is a host command: pop it from the list
self
.
mainqueue
.
pop
(
self
.
queueindex
)
self
.
processHostCommand
(
tline
)
return
tline
=
tline
.
split
(
";"
)[
0
]
tline
=
tline
.
split
(
";"
)[
0
]
if
len
(
tline
)
>
0
:
if
len
(
tline
)
>
0
:
self
.
_send
(
tline
,
self
.
lineno
,
True
)
self
.
_send
(
tline
,
self
.
lineno
,
True
)
...
...
pronterface.py
View file @
360b4f60
...
@@ -85,7 +85,7 @@ class Tee(object):
...
@@ -85,7 +85,7 @@ class Tee(object):
class
PronterWindow
(
MainWindow
,
pronsole
.
pronsole
):
class
PronterWindow
(
MainWindow
,
pronsole
.
pronsole
):
def
__init__
(
self
,
filename
=
None
,
size
=
winsize
):
def
__init__
(
self
,
filename
=
None
,
size
=
winsize
):
pronsole
.
pronsole
.
__init__
(
self
)
pronsole
.
pronsole
.
__init__
(
self
)
self
.
settings
.
build_dimensions
=
'200x200x100+0+0+0'
#default build dimensions are 200x200x100 with 0, 0, 0 in the corner of the bed
self
.
settings
.
build_dimensions
=
'200x200x100+0+0+0
+0+0+0
'
#default build dimensions are 200x200x100 with 0, 0, 0 in the corner of the bed
self
.
settings
.
last_bed_temperature
=
0.0
self
.
settings
.
last_bed_temperature
=
0.0
self
.
settings
.
last_file_path
=
""
self
.
settings
.
last_file_path
=
""
self
.
settings
.
last_temperature
=
0.0
self
.
settings
.
last_temperature
=
0.0
...
@@ -93,7 +93,11 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -93,7 +93,11 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
settings
.
preview_grid_step1
=
10.
self
.
settings
.
preview_grid_step1
=
10.
self
.
settings
.
preview_grid_step2
=
50.
self
.
settings
.
preview_grid_step2
=
50.
self
.
settings
.
bgcolor
=
"#FFFFFF"
self
.
settings
.
bgcolor
=
"#FFFFFF"
self
.
helpdict
[
"build_dimensions"
]
=
_
(
"Dimensions of Build Platform
\n
& optional offset of origin
\n\n
Examples:
\n
XXXxYYY
\n
XXX,YYY,ZZZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ"
)
self
.
pauseScript
=
"pause.gcode"
self
.
endScript
=
"end.gcode"
self
.
helpdict
[
"build_dimensions"
]
=
_
(
"Dimensions of Build Platform
\n
& optional offset of origin
\n
& optional switch position
\n\n
Examples:
\n
XXXxYYY
\n
XXX,YYY,ZZZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ
\n
XXXxYYYxZZZ+OffX+OffY+OffZ+HomeX+HomeY+HomeZ"
)
self
.
helpdict
[
"last_bed_temperature"
]
=
_
(
"Last Set Temperature for the Heated Print Bed"
)
self
.
helpdict
[
"last_bed_temperature"
]
=
_
(
"Last Set Temperature for the Heated Print Bed"
)
self
.
helpdict
[
"last_file_path"
]
=
_
(
"Folder of last opened file"
)
self
.
helpdict
[
"last_file_path"
]
=
_
(
"Folder of last opened file"
)
self
.
helpdict
[
"last_temperature"
]
=
_
(
"Last Temperature of the Hot End"
)
self
.
helpdict
[
"last_temperature"
]
=
_
(
"Last Temperature of the Hot End"
)
...
@@ -130,20 +134,24 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -130,20 +134,24 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
build_dimensions_list
=
self
.
get_build_dimensions
(
self
.
settings
.
build_dimensions
)
self
.
build_dimensions_list
=
self
.
get_build_dimensions
(
self
.
settings
.
build_dimensions
)
#initialize the code analyzer with the correct sizes. There must be a more general way to do so
#initialize the code analyzer with the correct sizes. There must be a more general way to do so
self
.
p
.
analyzer
.
maxX
=
self
.
build_dimensions_list
[
0
];
self
.
p
.
analyzer
.
maxX
=
self
.
build_dimensions_list
[
0
]
if
self
.
build_dimensions_list
[
0
]
>=
self
.
build_dimensions_list
[
6
]
else
self
.
build_dimensions_list
[
6
]
# maximum x is maximum x if maximum X > home X, else it is home X
self
.
p
.
analyzer
.
maxY
=
self
.
build_dimensions_list
[
1
];
self
.
p
.
analyzer
.
maxY
=
self
.
build_dimensions_list
[
1
]
if
self
.
build_dimensions_list
[
1
]
>=
self
.
build_dimensions_list
[
7
]
else
self
.
build_dimensions_list
[
7
]
self
.
p
.
analyzer
.
maxZ
=
self
.
build_dimensions_list
[
2
];
self
.
p
.
analyzer
.
maxZ
=
self
.
build_dimensions_list
[
2
]
if
self
.
build_dimensions_list
[
2
]
>=
self
.
build_dimensions_list
[
8
]
else
self
.
build_dimensions_list
[
8
]
self
.
p
.
analyzer
.
homeX
=
self
.
build_dimensions_list
[
3
];
self
.
p
.
analyzer
.
homeY
=
self
.
build_dimensions_list
[
4
];
self
.
p
.
analyzer
.
homeZ
=
self
.
build_dimensions_list
[
5
];
self
.
p
.
analyzer
.
print_status
()
self
.
p
.
analyzer
.
minX
=
self
.
build_dimensions_list
[
3
]
self
.
p
.
analyzer
.
minY
=
self
.
build_dimensions_list
[
4
]
self
.
p
.
analyzer
.
minZ
=
self
.
build_dimensions_list
[
5
]
self
.
p
.
analyzer
.
homeX
=
self
.
build_dimensions_list
[
6
]
self
.
p
.
analyzer
.
homeY
=
self
.
build_dimensions_list
[
7
]
self
.
p
.
analyzer
.
homeZ
=
self
.
build_dimensions_list
[
8
]
#set feedrates in printcore for pause/resume
#set feedrates in printcore for pause/resume
self
.
p
.
xy_feedrate
=
self
.
settings
.
xy_feedrate
self
.
p
.
xy_feedrate
=
self
.
settings
.
xy_feedrate
self
.
p
.
z_feedrate
=
self
.
settings
.
z_feedrate
self
.
p
.
z_feedrate
=
self
.
settings
.
z_feedrate
#make printcore aware of me
self
.
p
.
pronterface
=
self
self
.
panel
.
SetBackgroundColour
(
self
.
settings
.
bgcolor
)
self
.
panel
.
SetBackgroundColour
(
self
.
settings
.
bgcolor
)
customdict
=
{}
customdict
=
{}
...
@@ -215,6 +223,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -215,6 +223,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
wx
.
CallAfter
(
self
.
pausebtn
.
Disable
)
wx
.
CallAfter
(
self
.
pausebtn
.
Disable
)
wx
.
CallAfter
(
self
.
printbtn
.
SetLabel
,
_
(
"Print"
))
wx
.
CallAfter
(
self
.
printbtn
.
SetLabel
,
_
(
"Print"
))
self
.
p
.
runSmallScript
(
self
.
endScript
)
param
=
self
.
settings
.
final_command
param
=
self
.
settings
.
final_command
if
not
param
:
if
not
param
:
return
return
...
@@ -1405,7 +1415,9 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1405,7 +1415,9 @@ class PronterWindow(MainWindow, pronsole.pronsole):
#print "Not printing, cannot pause."
#print "Not printing, cannot pause."
return
return
self
.
p
.
pause
()
self
.
p
.
pause
()
self
.
p
.
runSmallScript
(
self
.
pauseScript
)
self
.
paused
=
True
self
.
paused
=
True
#self.p.runSmallScript(self.pauseScript)
self
.
extra_print_time
+=
int
(
time
.
time
()
-
self
.
starttime
)
self
.
extra_print_time
+=
int
(
time
.
time
()
-
self
.
starttime
)
wx
.
CallAfter
(
self
.
pausebtn
.
SetLabel
,
_
(
"Resume"
))
wx
.
CallAfter
(
self
.
pausebtn
.
SetLabel
,
_
(
"Resume"
))
else
:
else
:
...
@@ -1544,9 +1556,12 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1544,9 +1556,12 @@ class PronterWindow(MainWindow, pronsole.pronsole):
"[^
\
d+-]*(
\
d+)?"
+
# Z build size
"[^
\
d+-]*(
\
d+)?"
+
# Z build size
"[^
\
d+-]*([+-]
\
d+)?"
+
# X corner coordinate
"[^
\
d+-]*([+-]
\
d+)?"
+
# X corner coordinate
"[^
\
d+-]*([+-]
\
d+)?"
+
# Y corner coordinate
"[^
\
d+-]*([+-]
\
d+)?"
+
# Y corner coordinate
"[^
\
d+-]*([+-]
\
d+)?"
# Z corner coordinate
"[^
\
d+-]*([+-]
\
d+)?"
+
# Z corner coordinate
"[^
\
d+-]*([+-]
\
d+)?"
+
# X endstop
"[^
\
d+-]*([+-]
\
d+)?"
+
# Y endstop
"[^
\
d+-]*([+-]
\
d+)?"
# Z endstop
,
bdim
)
.
groups
()
,
bdim
)
.
groups
()
defaults
=
[
200
,
200
,
100
,
0
,
0
,
0
]
defaults
=
[
200
,
200
,
100
,
0
,
0
,
0
,
0
,
0
,
0
]
bdl_float
=
[
float
(
value
)
if
value
else
defaults
[
i
]
for
i
,
value
in
enumerate
(
bdl
)]
bdl_float
=
[
float
(
value
)
if
value
else
defaults
[
i
]
for
i
,
value
in
enumerate
(
bdl
)]
return
bdl_float
return
bdl_float
...
...
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