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
aeffb1c6
Commit
aeffb1c6
authored
Apr 11, 2013
by
D1plo1d
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding temperature graphing to the pronsole inspector
parent
a5c1ae9d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
12 deletions
+69
-12
pronserve.py
pronserve.py
+2
-3
inspect.css
server/static/css/inspect.css
+7
-2
inspect.js
server/static/js/inspect.js
+47
-1
inspect.html
server/templates/inspect.html
+13
-6
No files found.
pronserve.py
View file @
aeffb1c6
...
@@ -87,7 +87,7 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
...
@@ -87,7 +87,7 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
print
"WebSocket opened.
%
i sockets currently open."
%
len
(
pronserve
.
clients
)
print
"WebSocket opened.
%
i sockets currently open."
%
len
(
pronserve
.
clients
)
def
on_sensor_change
(
self
):
def
on_sensor_change
(
self
):
self
.
write_message
({
'sensors'
:
pronserve
.
sensors
})
self
.
write_message
({
'sensors'
:
pronserve
.
sensors
,
'timestamp'
:
time
.
time
()
})
def
on_pronsole_log
(
self
,
msg
):
def
on_pronsole_log
(
self
,
msg
):
self
.
write_message
({
'log'
:
{
msg
:
msg
,
level
:
"debug"
}})
self
.
write_message
({
'log'
:
{
msg
:
msg
,
level
:
"debug"
}})
...
@@ -169,7 +169,7 @@ class Pronserve(pronsole.pronsole):
...
@@ -169,7 +169,7 @@ class Pronserve(pronsole.pronsole):
#self.init_Settings()
#self.init_Settings()
self
.
ioloop
=
tornado
.
ioloop
.
IOLoop
.
instance
()
self
.
ioloop
=
tornado
.
ioloop
.
IOLoop
.
instance
()
self
.
clients
=
set
()
self
.
clients
=
set
()
self
.
settings
.
sensor_poll_rate
=
0.
7
# seconds
self
.
settings
.
sensor_poll_rate
=
0.
3
# seconds
self
.
sensors
=
{
'extruder'
:
-
1
,
'bed'
:
-
1
}
self
.
sensors
=
{
'extruder'
:
-
1
,
'bed'
:
-
1
}
self
.
load_default_rc
()
self
.
load_default_rc
()
#self.mdns = MdnsServer()
#self.mdns = MdnsServer()
...
@@ -183,7 +183,6 @@ class Pronserve(pronsole.pronsole):
...
@@ -183,7 +183,6 @@ class Pronserve(pronsole.pronsole):
def
request_sensor_update
(
self
):
def
request_sensor_update
(
self
):
if
self
.
p
.
online
:
self
.
p
.
send_now
(
"M105"
)
if
self
.
p
.
online
:
self
.
p
.
send_now
(
"M105"
)
self
.
fire
(
"sensor_change"
)
def
recvcb
(
self
,
l
):
def
recvcb
(
self
,
l
):
""" Parses a line of output from the printer via printcore """
""" Parses a line of output from the printer via printcore """
...
...
server/static/css/inspect.css
View file @
aeffb1c6
.sensors
.sensors
{
{
margin-
bottom
:
20
px
;
margin-
top
:
15
px
;
}
}
.sensors
>*
.sensors
>*
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
.console
.console
{
{
height
:
3
00px
;
height
:
2
00px
;
overflow-y
:
scroll
;
overflow-y
:
scroll
;
}
}
...
@@ -33,4 +33,9 @@
...
@@ -33,4 +33,9 @@
border
:
0px
;
border
:
0px
;
margin
:
0px
;
margin
:
0px
;
padding
:
0px
;
padding
:
0px
;
}
#temperature-graph
{
height
:
200px
;
}
}
\ No newline at end of file
server/static/js/inspect.js
View file @
aeffb1c6
...
@@ -15,6 +15,48 @@ var connect = function() {
...
@@ -15,6 +15,48 @@ var connect = function() {
});
});
};
};
var
updateSensors
=
function
()
{
$
(
".sensors .val"
).
each
(
function
()
{
$
(
this
).
html
(
$
(
this
).
data
(
"val"
)
||
"xx.x"
);
})
}.
throttle
(
800
);
var
graph
=
null
;
var
graphData
=
[];
var
graphResolution
=
40
;
var
updateGraph
=
function
(
current
)
{
current
.
time
=
Date
.
now
();
if
(
graphData
.
length
==
graphResolution
)
graphData
.
shift
();
graphData
.
push
(
current
);
if
(
graph
==
null
)
{
graph
=
new
Morris
.
Line
({
// ID of the element in which to draw the chart.
element
:
"temperature-graph"
,
// Chart data records -- each entry in this array corresponds to a point on
// the chart.
data
:
graphData
,
// The name of the data record attribute that contains x-values.
xkey
:
'timestamp'
,
// A list of names of data record attributes that contain y-values.
ykeys
:
[
'extruder'
,
'bed'
],
// Labels for the ykeys -- will be displayed when you hover over the
// chart.
labels
:
[
'extruder °C'
,
'bed °C'
],
hideHover
:
'always'
,
ymax
:
'auto 250'
,
//pointSize: 0,
//parseTime: false,
xLabels
:
"decade"
});
}
else
{
graph
.
setData
(
graphData
);
}
}
var
onConnect
=
function
(
ws
)
{
var
onConnect
=
function
(
ws
)
{
ws
.
onopen
=
function
()
ws
.
onopen
=
function
()
{
{
...
@@ -28,12 +70,16 @@ var onConnect = function(ws) {
...
@@ -28,12 +70,16 @@ var onConnect = function(ws) {
if
(
msg
.
sensors
!=
undefined
)
if
(
msg
.
sensors
!=
undefined
)
{
{
var
sensorNames
=
[
"bed"
,
"extruder"
];
var
sensorNames
=
[
"bed"
,
"extruder"
];
var
values
=
{
timestamp
:
msg
.
timestamp
};
for
(
var
i
=
0
;
i
<
sensorNames
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
sensorNames
.
length
;
i
++
)
{
{
var
name
=
sensorNames
[
i
];
var
name
=
sensorNames
[
i
];
var
val
=
parseFloat
(
msg
.
sensors
[
name
]);
var
val
=
parseFloat
(
msg
.
sensors
[
name
]);
$
(
"."
+
name
+
" .val"
).
html
(
val
.
format
(
1
));
values
[
name
]
=
val
;
$
(
"."
+
name
+
" .val"
).
data
(
"val"
,
val
.
format
(
1
))
}
}
updateSensors
();
updateGraph
(
values
);
}
}
$console
.
append
(
"
\n
"
+
evt
.
data
);
$console
.
append
(
"
\n
"
+
evt
.
data
);
$consoleWrapper
.
scrollTop
(
$console
.
innerHeight
());
$consoleWrapper
.
scrollTop
(
$console
.
innerHeight
());
...
...
server/templates/inspect.html
View file @
aeffb1c6
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<head>
<head>
<title>
Pronserve Inspector
</title>
<title>
Pronserve Inspector
</title>
<link
href=
"//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css"
rel=
"stylesheet"
>
<link
href=
"//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css"
rel=
"stylesheet"
>
<link
rel=
"stylesheet"
href=
"http://cdn.oesmith.co.uk/morris-0.4.1.min.css"
>
<link
href=
"/static/css/inspect.css"
rel=
"stylesheet"
>
<link
href=
"/static/css/inspect.css"
rel=
"stylesheet"
>
</head>
</head>
...
@@ -14,19 +15,23 @@
...
@@ -14,19 +15,23 @@
<h1>
<h1>
Pronserve Inspector
Pronserve Inspector
</h1>
</h1>
<div
class=
"sensors"
>
<h2>
Console
</h2>
<div
class=
"well console"
>
<pre>
Connecting...
</pre>
</div>
<div
class=
"sensors pull-right"
>
<div
class=
"extruder pull-right"
>
<div
class=
"extruder pull-right"
>
Extruder:
<span
class=
"val"
>
xx.x
</span><span
class=
"deg"
>
°
C
</span>
Extruder:
<span
class=
"val"
>
xx.x
</span><span
class=
"deg"
>
°
C
</span>
</div>
</div>
<div
class=
"bed pull-right"
>
<div
class=
"bed pull-right"
>
Bed:
<span
class=
"val"
/>
xx.x
</span><span
class=
"deg"
>
°
C
</span>
Bed:
<span
class=
"val"
/>
xx.x
</span><span
class=
"deg"
>
°
C
</span>
</div>
</div>
<div
class=
"clearfix"
></div>
</div>
</div>
<div
class=
"well console"
>
<h2>
Temperature
</h2>
<pre>
<div
class=
"clearfix"
></div>
Connecting...
<div
id=
"temperature-graph"
>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -36,6 +41,8 @@
...
@@ -36,6 +41,8 @@
<script
src=
"http://code.jquery.com/jquery-1.9.1.min.js"
></script>
<script
src=
"http://code.jquery.com/jquery-1.9.1.min.js"
></script>
<script
src=
"//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"
></script>
<script
src=
"//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/sugar/1.3.9/sugar.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/sugar/1.3.9/sugar.min.js"
></script>
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"
></script>
<script
src=
"http://cdn.oesmith.co.uk/morris-0.4.1.min.js"
></script>
<script
src=
"/static/js/inspect.js"
></script>
<script
src=
"/static/js/inspect.js"
></script>
</body>
</body>
...
...
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