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
6f49adca
Commit
6f49adca
authored
Jul 09, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:kliment/Printrun
parents
55da08b8
6791f2c9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
30 deletions
+93
-30
inspect.js
printrun/server/static/js/inspect.js
+1
-1
prontserve.py
prontserve.py
+92
-29
No files found.
printrun/server/static/js/inspect.js
View file @
6f49adca
...
...
@@ -22,7 +22,7 @@
var
hostname
=
window
.
location
.
hostname
;
var
url
=
"ws://"
+
hostname
+
":8888/socket?user=admin&password=admin"
;
console
.
log
(
url
);
var
ws
=
new
WebSocket
(
url
,
"construct.text.0.
0.1
"
);
var
ws
=
new
WebSocket
(
url
,
"construct.text.0.
2
"
);
$
(
function
()
{
$consoleWrapper
=
$
(
".console"
);
$console
=
$
(
".console pre"
);
...
...
prontserve.py
View file @
6f49adca
...
...
@@ -402,6 +402,46 @@ class EventEmitter(object):
continue
# Fast GCode. Because the GCode class is slow.
# -------------------------------------------------
class
PyLine
(
object
):
__slots__
=
(
'x'
,
'y'
,
'z'
,
'e'
,
'f'
,
'i'
,
'j'
,
'raw'
,
'command'
,
'is_move'
,
'relative'
,
'relative_e'
,
'current_x'
,
'current_y'
,
'current_z'
,
'extruding'
,
'current_tool'
,
'gcview_end_vertex'
)
def
__init__
(
self
,
l
):
self
.
raw
=
l
def
__getattr__
(
self
,
name
):
return
None
try
:
from
printrun
import
gcoder_line
Line
=
gcoder_line
.
GLine
except
ImportError
:
Line
=
PyLine
class
FastGCode
(
object
):
def
__init__
(
self
,
data
):
self
.
lines
=
[
Line
(
l2
)
for
l2
in
(
l
.
strip
()
for
l
in
data
)
if
l2
]
self
.
all_layers
=
[
self
.
lines
]
def
__len__
(
self
):
return
len
(
self
.
lines
)
def
__iter__
(
self
):
return
self
.
lines
.
__iter__
()
def
idxs
(
self
,
index
):
return
(
0
,
index
)
# Prontserve: Server-specific functionality
# -------------------------------------------------
...
...
@@ -445,8 +485,10 @@ class Prontserve(pronsole.pronsole, EventEmitter):
sdRef
.
close
()
def
do_print
(
self
):
if
not
self
.
p
.
online
:
raise
Exception
(
"not online"
)
if
self
.
printing_jobs
:
raise
Exception
(
"already printing"
)
if
not
self
.
p
.
online
:
raise
Exception
(
"Not online"
)
if
self
.
printing_jobs
:
raise
Exception
(
"Already printing"
)
no_jobs_msg
=
"Nothing to print. Try adding a print job with add_job."
if
len
(
self
.
jobs
.
list
)
==
0
:
raise
Exception
(
no_jobs_msg
)
self
.
printing_jobs
=
True
def
do_home
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -479,6 +521,21 @@ class Prontserve(pronsole.pronsole, EventEmitter):
raise
Exception
(
"Continuous movement not supported"
)
def
do_estop
(
self
):
self
.
reset
()
print
"Emergency Stop!"
self
.
fire
(
"estop"
)
# Updating the job progress
print
self
.
print_progress
()
self
.
update_job_progress
(
self
.
print_progress
())
for
k
,
v
in
self
.
target_values
.
iteritems
():
self
.
_set_target_temp
(
k
,
0
)
self
.
do_set_motors
(
"off"
)
self
.
do_set_fan
(
"off"
)
progress
=
{
'eta'
:
0
,
'percent'
:
100
}
self
.
fire
(
"target_temp_progress_changed"
,
{
'e0'
:
progress
})
def
reset
(
self
):
self
.
printing_jobs
=
False
self
.
current_job
=
None
self
.
waiting_to_reach_temp
=
False
...
...
@@ -492,8 +549,9 @@ class Prontserve(pronsole.pronsole, EventEmitter):
# restart the firmware
pronsole
.
pronsole
.
do_reset
(
self
,
""
)
print
"Emergency Stop!"
self
.
fire
(
"estop"
)
self
.
p
.
printing
=
False
def
do_construct_set
(
self
,
subCmd
,
*
args
,
**
kwargs
):
method
=
"do_set_
%
s"
%
subCmd
...
...
@@ -562,6 +620,7 @@ class Prontserve(pronsole.pronsole, EventEmitter):
# A better solution would be one in which a print_finised event could be
# listend for asynchronously without polling.
p
=
self
.
p
try
:
if
self
.
printing_jobs
and
p
.
printing
==
False
and
p
.
online
:
if
self
.
current_job
!=
None
:
self
.
update_job_progress
(
100
)
...
...
@@ -574,7 +633,8 @@ class Prontserve(pronsole.pronsole, EventEmitter):
elif
len
(
self
.
jobs
.
list
)
>
0
:
print
"Starting the next print job"
self
.
current_job
=
self
.
jobs
.
list
.
pop
(
0
)
gc
=
gcoder
.
GCode
(
self
.
current_job
[
'body'
]
.
split
(
"
\n
"
))
lines
=
self
.
current_job
[
'body'
]
.
split
(
"
\n
"
)
gc
=
FastGCode
(
lines
)
self
.
p
.
startprint
(
gc
)
self
.
p
.
paused
=
False
self
.
fire
(
"job_started"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
...
...
@@ -586,12 +646,15 @@ class Prontserve(pronsole.pronsole, EventEmitter):
# Updating the job progress
self
.
update_job_progress
(
self
.
print_progress
())
except
Exception
as
ex
:
print
traceback
.
format_exc
()
#print "print loop"
next_timeout
=
time
.
time
()
+
0.3
gen
.
Task
(
self
.
ioloop
.
add_timeout
(
next_timeout
,
self
.
run_print_queue_loop
))
def
update_job_progress
(
self
,
progress
):
if
progress
!=
self
.
previous_job_progress
and
self
.
current_job
!=
None
:
if
progress
!=
self
.
previous_job_progress
:
self
.
previous_job_progress
=
progress
self
.
fire
(
"job_progress_changed"
,
progress
)
...
...
@@ -600,7 +663,7 @@ class Prontserve(pronsole.pronsole, EventEmitter):
return
100
*
float
(
self
.
p
.
queueindex
)
/
len
(
self
.
p
.
mainqueue
)
if
(
self
.
sdprinting
):
return
self
.
percentdone
return
"0"
return
0
def
run_sensor_loop
(
self
):
# A number of conditions that must be met for us to send a temperature
...
...
@@ -821,7 +884,7 @@ if __name__ == "__main__":
sys
.
exit
(
1
)
time
.
sleep
(
2
)
prontserve
.
do_estop
()
prontserve
.
reset
()
prontserve
.
run_sensor_loop
()
prontserve
.
run_print_queue_loop
()
...
...
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