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
5e1a0be4
Commit
5e1a0be4
authored
May 23, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use arrays for storing layer/line ids instead of an heavy list of tuples
parent
2a6eec73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
printcore.py
printcore.py
+2
-2
gcoder.py
printrun/gcoder.py
+15
-6
No files found.
printcore.py
View file @
5e1a0be4
...
...
@@ -380,8 +380,8 @@ class printcore():
if
self
.
priqueue
:
self
.
_send
(
self
.
priqueue
.
pop
(
0
))
return
if
self
.
printing
and
self
.
queueindex
<
len
(
self
.
mainqueue
.
idxs
):
(
layer
,
line
)
=
self
.
mainqueue
.
idxs
[
self
.
queueindex
]
if
self
.
printing
and
self
.
queueindex
<
len
(
self
.
mainqueue
):
(
layer
,
line
)
=
self
.
mainqueue
.
idxs
(
self
.
queueindex
)
gline
=
self
.
mainqueue
.
all_layers
[
layer
]
.
lines
[
line
]
tline
=
gline
.
raw
#check for host command
...
...
printrun/gcoder.py
View file @
5e1a0be4
...
...
@@ -18,6 +18,7 @@ import sys
import
re
import
math
import
datetime
from
array
import
array
gcode_parsed_args
=
[
"x"
,
"y"
,
"e"
,
"f"
,
"z"
,
"p"
,
"i"
,
"j"
,
"s"
]
gcode_exp
=
re
.
compile
(
"
\
([^
\
(
\
)]*
\
)|;.*|[/
\
*].*
\n
|[a-z][-+]?[0-9]*
\
.?[0-9]*"
)
...
...
@@ -119,7 +120,8 @@ class GCode(object):
lines
=
None
layers
=
None
all_layers
=
None
idxs
=
None
layer_idxs
=
None
line_idxs
=
None
append_layer
=
None
append_layer_id
=
None
...
...
@@ -148,7 +150,7 @@ class GCode(object):
self
.
_preprocess_layers
()
def
__len__
(
self
):
return
len
(
self
.
idxs
)
return
len
(
self
.
line_
idxs
)
def
append
(
self
,
command
):
command
=
command
.
strip
()
...
...
@@ -158,7 +160,8 @@ class GCode(object):
self
.
lines
.
append
(
gline
)
self
.
_preprocess
([
gline
])
self
.
append_layer
.
lines
.
append
(
gline
)
self
.
idxs
.
append
((
self
.
append_layer_id
,
len
(
self
.
append_layer
.
lines
)))
self
.
layer_idxs
.
append
(
self
.
append_layer_id
)
self
.
line_idxs
.
append
(
len
(
self
.
append_layer
.
lines
))
def
_preprocess_lines
(
self
,
lines
=
None
):
"""Checks for G20, G21, G90 and G91, sets imperial and relative flags"""
...
...
@@ -217,7 +220,8 @@ class GCode(object):
def
_create_layers
(
self
):
layers
=
{}
all_layers
=
[]
idxs
=
[]
layer_idxs
=
[]
line_idxs
=
[]
layer_id
=
0
layer_line
=
0
...
...
@@ -245,7 +249,8 @@ class GCode(object):
layer_line
=
0
cur_lines
.
append
(
line
)
idxs
.
append
((
layer_id
,
layer_line
))
layer_idxs
.
append
(
layer_id
)
line_idxs
.
append
(
layer_line
)
layer_line
+=
1
prev_z
=
cur_z
...
...
@@ -272,7 +277,11 @@ class GCode(object):
all_layers
.
append
(
self
.
append_layer
)
self
.
all_layers
=
all_layers
self
.
layers
=
layers
self
.
idxs
=
idxs
self
.
layer_idxs
=
array
(
'I'
,
layer_idxs
)
self
.
line_idxs
=
array
(
'I'
,
line_idxs
)
def
idxs
(
self
,
i
):
return
self
.
layer_idxs
[
i
],
self
.
line_idxs
[
i
]
def
num_layers
(
self
):
return
len
(
self
.
layers
)
...
...
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