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
a46f7359
Commit
a46f7359
authored
May 15, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GCoder parsed gcode in gviz
parent
ea604380
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
6 deletions
+67
-6
gcoder.py
gcoder.py
+4
-3
gviz.py
printrun/gviz.py
+63
-3
No files found.
gcoder.py
View file @
a46f7359
...
@@ -19,7 +19,7 @@ import re
...
@@ -19,7 +19,7 @@ import re
import
math
import
math
import
datetime
import
datetime
gcode_parsed_args
=
[
"x"
,
"y"
,
"e"
,
"f"
,
"z"
,
"p"
]
gcode_parsed_args
=
[
"x"
,
"y"
,
"e"
,
"f"
,
"z"
,
"p"
,
"i"
,
"j"
]
class
Line
(
object
):
class
Line
(
object
):
...
@@ -28,6 +28,8 @@ class Line(object):
...
@@ -28,6 +28,8 @@ class Line(object):
z
=
None
z
=
None
e
=
None
e
=
None
f
=
None
f
=
None
i
=
None
j
=
None
relative
=
False
relative
=
False
relative_e
=
False
relative_e
=
False
...
@@ -263,7 +265,6 @@ class GCode(object):
...
@@ -263,7 +265,6 @@ class GCode(object):
#TODO:
#TODO:
# get device caps from firmware: max speed, acceleration/axis (including extruder)
# get device caps from firmware: max speed, acceleration/axis (including extruder)
# calculate the maximum move duration accounting for above ;)
# calculate the maximum move duration accounting for above ;)
# self.log(".... estimating ....")
zs
=
self
.
layers
.
keys
()
zs
=
self
.
layers
.
keys
()
zs
.
sort
()
zs
.
sort
()
for
z
in
zs
:
for
z
in
zs
:
...
@@ -281,7 +282,7 @@ class GCode(object):
...
@@ -281,7 +282,7 @@ class GCode(object):
x
=
line
.
x
if
line
.
x
!=
None
else
lastx
x
=
line
.
x
if
line
.
x
!=
None
else
lastx
y
=
line
.
y
if
line
.
y
!=
None
else
lasty
y
=
line
.
y
if
line
.
y
!=
None
else
lasty
e
=
line
.
e
if
line
.
e
!=
None
else
laste
e
=
line
.
e
if
line
.
e
!=
None
else
laste
f
=
line
.
f
/
60.0
if
line
.
f
!=
None
else
lastf
# mm/s vs mm/m
f
=
line
.
f
/
60.0
if
line
.
f
!=
None
else
lastf
# mm/s vs mm/m
=> divide by 60
# given last feedrate and current feedrate calculate the distance needed to achieve current feedrate.
# given last feedrate and current feedrate calculate the distance needed to achieve current feedrate.
# if travel is longer than req'd distance, then subtract distance to achieve full speed, and add the time it took to get there.
# if travel is longer than req'd distance, then subtract distance to achieve full speed, and add the time it took to get there.
...
...
printrun/gviz.py
View file @
a46f7359
...
@@ -312,10 +312,70 @@ class gviz(wx.Panel):
...
@@ -312,10 +312,70 @@ class gviz(wx.Panel):
dc
.
DrawBitmap
(
self
.
blitmap
,
0
,
0
)
dc
.
DrawBitmap
(
self
.
blitmap
,
0
,
0
)
del
dc
del
dc
def
addfile
(
self
,
gcode
s
=
[]
):
def
addfile
(
self
,
gcode
):
self
.
clear
()
self
.
clear
()
for
i
in
gcodes
:
self
.
add_parsed_gcodes
(
gcode
.
lines
)
self
.
addgcode
(
i
)
def
add_parsed_gcodes
(
self
,
lines
,
hilight
=
0
):
def
_readgcode
():
target
=
self
.
lastpos
[:]
target
[
5
]
=
0.0
target
[
6
]
=
0.0
if
hilight
:
target
=
self
.
hilightpos
[:]
if
gline
.
x
!=
None
:
target
[
0
]
=
gline
.
x
if
gline
.
y
!=
None
:
target
[
1
]
=
gline
.
y
if
gline
.
z
!=
None
:
target
[
2
]
=
gline
.
z
if
gline
.
e
!=
None
:
target
[
3
]
=
gline
.
e
if
gline
.
f
!=
None
:
target
[
4
]
=
gline
.
f
if
gline
.
i
!=
None
:
target
[
5
]
=
gline
.
i
if
gline
.
j
!=
None
:
target
[
6
]
=
gline
.
j
if
not
hilight
:
if
not
target
[
2
]
in
self
.
lines
.
keys
():
self
.
lines
[
target
[
2
]]
=
[]
self
.
pens
[
target
[
2
]]
=
[]
self
.
arcs
[
target
[
2
]]
=
[]
self
.
arcpens
[
target
[
2
]]
=
[]
self
.
layers
+=
[
target
[
2
]]
return
target
def
_y
(
y
):
return
self
.
build_dimensions
[
1
]
-
(
y
-
self
.
build_dimensions
[
4
])
def
_x
(
x
):
return
x
-
self
.
build_dimensions
[
3
]
for
gline
in
lines
:
start_pos
=
self
.
hilightpos
[:]
if
hilight
else
self
.
lastpos
[:]
if
gline
.
command
in
[
"G0"
,
"G1"
]:
target
=
_readgcode
()
line
=
[
_x
(
start_pos
[
0
]),
_y
(
start_pos
[
1
]),
_x
(
target
[
0
]),
_y
(
target
[
1
])
]
if
not
hilight
:
self
.
lines
[
target
[
2
]
]
+=
[
line
]
self
.
pens
[
target
[
2
]
]
+=
[
self
.
mainpen
if
target
[
3
]
!=
self
.
lastpos
[
3
]
else
self
.
travelpen
]
self
.
lastpos
=
target
else
:
self
.
hilight
+=
[
line
]
self
.
hilightpos
=
target
self
.
dirty
=
1
if
gline
.
command
in
[
"G2"
,
"G3"
]:
target
=
_readgcode
()
arc
=
[]
arc
+=
[
_x
(
start_pos
[
0
]),
_y
(
start_pos
[
1
])
]
arc
+=
[
_x
(
target
[
0
]),
_y
(
target
[
1
])
]
arc
+=
[
_x
(
start_pos
[
0
]
+
target
[
5
]),
_y
(
start_pos
[
1
]
+
target
[
6
])
]
# center
if
gline
.
command
==
"G2"
:
# clockwise, reverse endpoints
arc
[
0
],
arc
[
1
],
arc
[
2
],
arc
[
3
]
=
arc
[
2
],
arc
[
3
],
arc
[
0
],
arc
[
1
]
if
not
hilight
:
self
.
arcs
[
target
[
2
]
]
+=
[
arc
]
self
.
arcpens
[
target
[
2
]
]
+=
[
self
.
arcpen
]
self
.
lastpos
=
target
else
:
self
.
hilightarcs
+=
[
arc
]
self
.
hilightpos
=
target
self
.
dirty
=
1
def
addgcode
(
self
,
gcode
=
"M105"
,
hilight
=
0
):
def
addgcode
(
self
,
gcode
=
"M105"
,
hilight
=
0
):
gcode
=
gcode
.
split
(
"*"
)[
0
]
gcode
=
gcode
.
split
(
"*"
)[
0
]
...
...
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