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
8feb30b2
Commit
8feb30b2
authored
Jun 15, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refactoring of gcoder argument parsing
parent
8f94f962
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
gcoder.py
printrun/gcoder.py
+10
-5
pronterface.py
pronterface.py
+7
-6
No files found.
printrun/gcoder.py
View file @
8feb30b2
...
...
@@ -21,8 +21,10 @@ import datetime
from
array
import
array
gcode_parsed_args
=
[
"x"
,
"y"
,
"e"
,
"f"
,
"z"
,
"i"
,
"j"
]
gcode_exp
=
re
.
compile
(
"
\
([^
\
(
\
)]*
\
)|;.*|[/
\
*].*
\n
|[a-z][-+]?[0-9]*
\
.?[0-9]*"
)
m114_exp
=
re
.
compile
(
"
\
([^
\
(
\
)]*
\
)|[/
\
*].*
\n
|[A-Z]:?[-+]?[0-9]*
\
.?[0-9]*"
)
gcode_parsed_nonargs
=
[
"g"
,
"t"
,
"m"
,
"n"
]
to_parse
=
""
.
join
(
gcode_parsed_args
+
gcode_parsed_nonargs
)
gcode_exp
=
re
.
compile
(
"
\
([^
\
(
\
)]*
\
)|;.*|[/
\
*].*
\n
|([
%
s])([-+]?[0-9]*
\
.?[0-9]*)"
%
to_parse
)
m114_exp
=
re
.
compile
(
"
\
([^
\
(
\
)]*
\
)|[/
\
*].*
\n
|([XYZ]):?([-+]?[0-9]*
\
.?[0-9]*)"
)
specific_exp
=
"(?:
\
([^
\
(
\
)]*
\
))|(?:;.*)|(?:[/
\
*].*
\n
)|(
%
s[-+]?[0-9]*
\
.?[0-9]*)"
move_gcodes
=
[
"G0"
,
"G1"
,
"G2"
,
"G3"
]
...
...
@@ -61,7 +63,8 @@ def P(line):
def
split
(
line
):
split_raw
=
gcode_exp
.
findall
(
line
.
raw
.
lower
())
line
.
command
=
split_raw
[
0
]
.
upper
()
if
not
split_raw
[
0
]
.
startswith
(
"n"
)
else
split_raw
[
1
]
.
upper
()
command
=
split_raw
[
0
]
if
not
split_raw
[
0
]
==
"n"
else
split_raw
[
1
]
line
.
command
=
command
[
0
]
.
upper
()
+
command
[
1
]
line
.
is_move
=
line
.
command
in
move_gcodes
return
split_raw
...
...
@@ -72,8 +75,8 @@ def parse_coordinates(line, split_raw, imperial = False, force = False):
unit_factor
=
25.4
if
imperial
else
1
for
bit
in
split_raw
:
code
=
bit
[
0
]
if
code
in
gcode_parsed_args
and
len
(
bit
)
>
1
:
setattr
(
line
,
code
,
unit_factor
*
float
(
bit
[
1
:
]))
if
code
not
in
gcode_parsed_nonargs
and
bit
[
1
]
:
setattr
(
line
,
code
,
unit_factor
*
float
(
bit
[
1
]))
class
Layer
(
object
):
...
...
@@ -195,6 +198,8 @@ class GCode(object):
current_tool
=
self
.
current_tool
for
line
in
lines
:
split_raw
=
split
(
line
)
if
not
line
.
command
:
continue
if
line
.
is_move
:
line
.
relative
=
relative
line
.
relative_e
=
relative_e
...
...
pronterface.py
View file @
8feb30b2
...
...
@@ -1196,12 +1196,13 @@ class PronterWindow(MainWindow, pronsole.pronsole):
y
=
None
z
=
None
for
bit
in
bits
:
if
x
is
None
and
bit
.
startswith
(
"X"
):
x
=
float
(
bit
[
1
:]
.
replace
(
":"
,
""
))
elif
y
is
None
and
bit
.
startswith
(
"Y"
):
y
=
float
(
bit
[
1
:]
.
replace
(
":"
,
""
))
elif
z
is
None
and
bit
.
startswith
(
"Z"
):
z
=
float
(
bit
[
1
:]
.
replace
(
":"
,
""
))
if
not
bit
[
0
]:
continue
if
x
is
None
and
bit
[
0
]
==
"X"
:
x
=
float
(
bit
[
1
])
elif
y
is
None
and
bit
[
0
]
==
"Y"
:
y
=
float
(
bit
[
1
])
elif
z
is
None
and
bit
[
0
]
==
"Z"
:
z
=
float
(
bit
[
1
])
if
x
is
not
None
:
self
.
current_pos
[
0
]
=
x
if
y
is
not
None
:
self
.
current_pos
[
1
]
=
y
if
z
is
not
None
:
self
.
current_pos
[
2
]
=
z
...
...
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