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
b335a4cf
Commit
b335a4cf
authored
Mar 12, 2013
by
fsantini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
G-codes and relevant M-codes implemented (check for tabs/spaces)
parent
60158d5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
8 deletions
+60
-8
GCodeAnalyzer.py
GCodeAnalyzer.py
+60
-8
No files found.
GCodeAnalyzer.py
View file @
b335a4cf
...
...
@@ -60,21 +60,22 @@ class GCodeAnalyzer():
self
.
maxZ
=
150
# find a code in a gstring line
def
findCode
(
self
,
gcode
,
codeStr
):
# find a code in a gstring line
def
findCode
(
self
,
gcode
,
codeStr
):
pattern
=
re
.
compile
(
codeStr
+
"s*([
\
d.]*)"
,
re
.
I
)
m
=
re
.
match
(
pattern
,
gcode
)
if
m
==
None
:
return
None
return
None
else
return
m
.
group
(
1
)
return
m
.
group
(
1
)
def
Analyze
(
self
,
gcode
):
def
Analyze
(
self
,
gcode
):
code_g
=
self
.
findCode
(
gcode
,
"G"
)
code_m
=
self
.
findCode
(
gcode
,
"M"
)
# we have a g_code
if
code_g
!=
None
:
code_g
=
int
(
code_g
)
code_g
=
int
(
code_g
)
#get movement codes
if
code_g
==
0
or
code_g
==
1
or
code_g
==
2
or
code_g
==
3
:
...
...
@@ -97,7 +98,7 @@ class GCodeAnalyzer():
if
e
!=
0
:
eChanged
=
True
self
.
e
+=
e
else
:
else
:
#absolute coordinates
if
code_x
!=
None
:
self
.
x
=
self
.
xOffset
+
float
(
code_x
)
if
code_y
!=
None
:
self
.
y
=
self
.
yOffset
+
float
(
code_y
)
...
...
@@ -122,4 +123,55 @@ class GCodeAnalyzer():
code_e
=
self
.
findCode
(
gcode
,
"E"
)
homeAll
=
False
if
code_x
==
None
and
code_y
==
None
and
code_z
==
None
:
homeAll
=
True
\ No newline at end of file
if
code_x
!=
None
or
homeAll
:
self
.
xOffset
=
0
self
.
x
=
self
.
homeX
if
code_y
!=
None
or
homeAll
:
self
.
yOffset
=
0
self
.
y
=
self
.
homeY
if
code_z
!=
None
or
homeAll
:
self
.
zOffset
=
0
self
.
z
=
self
.
homeZ
if
code_e
!=
None
:
self
.
eOffset
=
0
self
.
e
=
0
elif
code_g
==
162
:
code_x
=
self
.
findCode
(
gcode
,
"X"
)
code_y
=
self
.
findCode
(
gcode
,
"Y"
)
code_z
=
self
.
findCode
(
gcode
,
"Z"
)
homeAll
=
False
if
code_x
==
None
and
code_y
==
None
and
code_z
==
None
:
homeAll
=
True
if
code_x
!=
None
or
homeAll
:
self
.
xOffset
=
0
self
.
x
=
self
.
maxX
if
code_y
!=
None
or
homeAll
:
self
.
yOffset
=
0
self
.
y
=
self
.
maxY
if
code_z
!=
None
or
homeAll
:
self
.
zOffset
=
0
self
.
z
=
self
.
maxZ
elif
code_g
==
90
:
self
.
relative
=
False
elif
code_g
==
91
:
self
.
relative
=
True
elif
code_g
==
92
:
code_x
=
self
.
findCode
(
gcode
,
"X"
)
code_y
=
self
.
findCode
(
gcode
,
"Y"
)
code_z
=
self
.
findCode
(
gcode
,
"Z"
)
code_e
=
self
.
findCode
(
gcode
,
"E"
)
if
code_x
!=
None
:
self
.
xOffset
=
self
.
x
-
float
(
code_x
)
self
.
x
=
self
.
xOffset
if
code_y
!=
None
:
self
.
yOffset
=
self
.
y
-
float
(
code_y
)
self
.
y
=
self
.
yOffset
if
code_z
!=
None
:
self
.
zOffset
=
self
.
z
-
float
(
code_z
)
self
.
z
=
self
.
zOffset
if
code_e
!=
None
:
self
.
xOffset
=
self
.
e
-
float
(
code_e
)
self
.
e
=
self
.
eOffset
#End code_g != None
if
code_m
!=
None
:
code_m
=
int
(
code_m
)
if
code_m
==
82
:
self
.
eRelative
=
False
elif
code_m
==
83
:
self
.
eRelative
=
True
\ No newline at end of file
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