kilnController/public/index.html

724 wiersze
18 KiB
HTML
Czysty Zwykły widok Historia

2013-11-23 21:42:23 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
2013-11-24 17:35:39 +00:00
2013-11-23 21:42:23 +00:00
<title>PicoReflow</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="assets/js/jquery-1.10.2.min.js"></script>
2013-11-24 17:35:39 +00:00
<script src="assets/js/highcharts.js"></script>
2013-11-23 21:42:23 +00:00
<script src="assets/js/draggable-points.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/select2.min.js"></script>
2013-11-24 17:35:39 +00:00
<link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
<link rel="stylesheet" href="assets/css/bootstrap-theme.min.css"/>
2013-11-23 21:42:23 +00:00
<link rel="stylesheet" href="assets/css/select2.css"/>
2013-11-24 17:35:39 +00:00
<link rel="stylesheet" href="assets/css/picoreflow.css"/>
2013-11-23 21:42:23 +00:00
</head>
<body>
<div class="container">
<!-- Static navbar -->
2013-11-24 19:32:04 +00:00
<div id="main_nav" class="navbar navbar-default" role="navigation">
2013-11-24 17:35:39 +00:00
<div class="pull-left" style="margin: 14px">
2013-11-24 17:54:23 +00:00
<span id="act_temp" class="display" style="color: #75890c">25 &deg;C</span>
<span id="target_temp" class="display">OFF</span>
2013-11-24 19:55:24 +00:00
<span id="state" class="display" style="font-size: 14px; text-align: center; padding-right:0">Idle</span>
2013-11-24 19:32:04 +00:00
<span id="eta" class="display" style="width: 60px">-</span>
<span id="power" class="display" style="width: 35px;">&nbsp;</span>
2013-11-24 17:35:39 +00:00
</div>
<div class="clearfix"></div>
<div class="progress progress-striped active" style="margin: 14px; margin-top: 0">
<div id="progressBar" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
<span class="sr-only"></span>
</div>
</div>
2013-11-23 23:32:13 +00:00
2013-11-23 21:42:23 +00:00
</div>
<!-- /Static navbar -->
<div class="panel panel-default">
<div class="panel-heading">
2013-11-24 18:42:19 +00:00
<select id="e2" style="margin-top: 5px"></select>
<div id="saveas" class="input-group" style="display:none">
<input id="form_profile_name" type="text" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-success" type="button" onclick="saveProfile();">Save</button>
</span>
</div><!-- /input-group -->
2013-11-23 21:42:23 +00:00
2013-11-24 19:55:24 +00:00
<div class="btn-group btn-group-sm">
2013-11-24 18:42:19 +00:00
<!--<button type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span></button>-->
<button type="button" class="btn btn-default" onclick="enterEditMode()"><span class="glyphicon glyphicon-pencil"></span></button>
2013-11-23 21:42:23 +00:00
</div>
2013-11-24 19:55:24 +00:00
<div class="pull-right">
<button id="nav_start" type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-forward"></span> Start</button>
<button id="nav_stop" type="button" class="btn btn-danger" onclick="abortTask()"><span class="glyphicon glyphicon-stop"></span> Stop</button>
</div>
2013-11-23 21:42:23 +00:00
</div>
<div class="panel-body" style='padding: 0'>
<div id="graph_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</div>
2013-11-24 18:42:19 +00:00
2013-11-23 21:42:23 +00:00
</div>
<div id="drag"></div>
<div id="drop"></div>
</div> <!-- /container -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
2013-11-24 16:56:41 +00:00
<h3 class="modal-title" id="myModalLabel">Task Overview</h3>
2013-11-23 21:42:23 +00:00
</div>
<div class="modal-body">
2013-11-24 14:10:48 +00:00
<table class="table table-bordered">
2013-11-24 16:56:41 +00:00
<tr><td>Selected Profile</td><td><b><span id="sel_prof"></span></b></td></tr>
2013-11-24 14:10:48 +00:00
<tr><td>Estimated Runtime</td><td><b>5 Minutes</b></td></tr>
2013-11-24 16:56:41 +00:00
<tr><td>Estimated Power consumption</td><td><b>0.320 kWh (EUR 0.08)</b></td></tr>
2013-11-24 14:10:48 +00:00
</table>
2013-11-23 21:42:23 +00:00
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
2013-11-24 16:56:41 +00:00
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="runTask()">Start Job</button>
2013-11-23 21:42:23 +00:00
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
2013-11-23 21:42:23 +00:00
function updateProgress(percentage){
2013-11-24 14:10:48 +00:00
if(state=="RUNNING") {
2013-11-23 21:42:23 +00:00
if(percentage > 100) percentage = 100;
$('#progressBar').css('width', percentage+'%');
2013-11-24 14:10:48 +00:00
if(percentage>=5) $('#progressBar').html(percentage+'%');
} else {
$('#progressBar').css('width', 0+'%');
$('#progressBar').html('');
}
2013-11-23 21:42:23 +00:00
}
2013-11-24 16:56:41 +00:00
function runTask() {
var test = {
"cmd": "RUN",
2013-11-24 17:01:48 +00:00
"profile": profiles[selected_profile]
2013-11-24 16:56:41 +00:00
}
2013-11-24 17:01:48 +00:00
console.log(JSON.stringify(test));
2013-11-24 16:56:41 +00:00
ws_control.send(JSON.stringify(test));
2013-11-24 19:32:04 +00:00
graph.series[1].setData([]);
2013-11-24 16:56:41 +00:00
}
2013-11-24 17:14:45 +00:00
function abortTask() {
var test = {"cmd": "STOP"};
console.log(JSON.stringify(test));
ws_control.send(JSON.stringify(test));
}
2013-11-24 18:42:19 +00:00
function enterEditMode() {
//$('#e2').hide();
$('#saveas').show();
$('#e2').select2('container').hide();
2013-11-24 19:32:04 +00:00
$('#main_nav').hide();
2013-11-24 18:42:19 +00:00
$('#form_profile_name').attr('value', profiles[selected_profile].name);
2013-11-24 19:32:04 +00:00
graph.series[0].options.marker.enabled=true;
graph.series[0].options.draggableX=true;
graph.series[0].options.draggableY=true;
graph.render();
2013-11-24 18:42:19 +00:00
}
function saveProfile() {
name = $('#form_profile_name').attr('value')
console.log('Trying to save profile: ' + name);
var rawdata = graph.series[0].data;
var data = [];
for(var i=0; i<rawdata.length;i++)
{
data.push([rawdata[i].x, rawdata[i].y]);
}
var profile = { "type": "profile", "data": data, "name": name }
var put = { "cmd": "PUT", "profile": profile }
var put_cmd = JSON.stringify(put);
ws_storage.send(put_cmd);
console.log('came to this: ' + put_cmd);
}
var state = "IDLE";
var graph;
var profiles = [];
2013-11-24 16:56:41 +00:00
var selected_profile = 0;
2013-11-24 15:06:22 +00:00
var host = "ws://" + window.location.hostname + ":8080";
2013-11-23 21:42:23 +00:00
// Status Socket ////////////////////////////////
2013-11-24 15:06:22 +00:00
var ws_status = new WebSocket(host+"/status");
ws_status.onopen = function()
2013-11-24 14:49:45 +00:00
{
2013-11-24 15:06:22 +00:00
console.log("Status Socket has been opened");
2013-11-24 14:49:45 +00:00
}
// Control Socket ////////////////////////////////
var ws_control = new WebSocket(host+"/control");
ws_control.onopen = function()
{
ws_control.onmessage = function(e)
{
console.log (e.data);
}
console.log("Control Socket has been opened");
}
// Storage Socket ///////////////////////////////
2013-11-24 14:49:45 +00:00
2013-11-24 15:06:22 +00:00
var ws_storage = new WebSocket(host+"/storage");
ws_storage.onopen = function()
2013-11-23 21:42:23 +00:00
{
2013-11-24 15:06:22 +00:00
console.log("Storage Socket has been opened");
ws_storage.onmessage = function(e)
{
console.log('Storage MSG:' + e.data);
profiles = JSON.parse(e.data);
console.log("Parsed profile:" + profiles);
2013-11-24 16:56:41 +00:00
//delete old options in select
$('#e2')
.find('option')
.remove()
.end();
2013-11-24 16:56:41 +00:00
// fill select with new options from websocket
for (var i=0; i<profiles.length; i++)
{
var profile = profiles[i];
console.log(profile.name);
$('#e2').append('<option value="'+i+'">'+profile.name+'</option>');
}
2013-11-24 16:56:41 +00:00
$('#e2').select2('val', '0');
update_profile(0);
2013-11-24 15:06:22 +00:00
}
2013-11-24 16:56:41 +00:00
2013-11-24 15:06:22 +00:00
console.log('Requesting stored profiles');
ws_storage.send('GET');
2013-11-24 16:56:41 +00:00
2013-11-23 21:42:23 +00:00
}
2013-11-24 15:06:22 +00:00
2013-11-23 21:42:23 +00:00
$("#e2").select2({
placeholder: "Temperature Curve",
allowClear: false
});
$("#e2").on("change", function(e) {
2013-11-24 16:56:41 +00:00
update_profile(e.val);
});
2013-11-24 16:56:41 +00:00
function update_profile(id) {
console.log('Profile selected:' + profiles[id].name);
selected_profile = id;
$('#sel_prof').html(profiles[id].name);
console.log(graph.series);
graph.series[0].setData(profiles[id].data);
}
2013-11-23 21:42:23 +00:00
Highcharts.theme = {
colors: ["#D8D3C5", "#75890c", "#c70000", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
"#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
chart: {
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#686764'],
[1, '#383734']
]
},
borderWidth: 0,
borderRadius: 0,
plotBackgroundColor: null,
plotShadow: true,
plotBorderWidth: 0,
marginBottom: 50
},
title: {
style: {
color: '#FFF',
font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
subtitle: {
style: {
color: '#DDD',
font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
xAxis: {
gridLineWidth: 1,
gridLineColor: 'rgba(255, 255, 255, .1)',
lineColor: 'rgba(255, 255, 255, .1)',
tickColor: 'rgba(255, 255, 255, .1)',
labels: {
style: {
paddingTop: '4px',
color: '#D8D3C5',
font: '15px Arial, Helvetica, sans-serif'
}
},
title: {
style: {
color: '#FFF',
font: '12px Arial, Helvetica, sans-serif'
}
}
},
yAxis: {
alternateGridColor: null,
minorTickInterval: null,
gridLineColor: 'rgba(255, 255, 255, .1)',
minorGridLineColor: 'rgba(255,255,255,0.05)',
lineWidth: 0,
tickWidth: 0,
labels: {
style: {
color: '#D8D3C5',
font: '15px Arial, Helvetica, sans-serif'
}
},
title: {
style: {
color: '#FFF',
font: '12px Arial, Helvetica, sans-serif'
}
}
},
legend: {
enabled: false,
itemStyle: {
color: '#CCC'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#333'
},
borderRadius: 0,
borderWidth: 0
},
labels: {
style: {
color: '#CCC'
}
},
tooltip: {
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, 'rgba(96, 96, 96, .8)'],
[1, 'rgba(16, 16, 16, .8)']
]
},
borderWidth: 0,
style: {
color: '#FFF'
}
},
plotOptions: {
series: {
shadow: true
},
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
}
},
toolbar: {
itemStyle: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
symbolStroke: '#DDDDDD',
hoverSymbolStroke: '#FFFFFF',
theme: {
fill: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
stroke: '#000000'
}
}
},
// scroll charts
rangeSelector: {
buttonTheme: {
fill: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
stroke: '#000000',
style: {
color: '#CCC',
fontWeight: 'bold'
},
states: {
hover: {
fill: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0.4, '#BBB'],
[0.6, '#888']
]
},
stroke: '#000000',
style: {
color: 'white'
}
},
select: {
fill: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0.1, '#000'],
[0.3, '#333']
]
},
stroke: '#000000',
style: {
color: 'yellow'
}
}
}
},
inputStyle: {
backgroundColor: '#333',
color: 'silver'
},
labelStyle: {
color: 'silver'
}
},
navigator: {
handles: {
backgroundColor: '#666',
borderColor: '#AAA'
},
outlineColor: '#CCC',
maskFill: 'rgba(16, 16, 16, 0.5)',
series: {
color: '#7798BF',
lineColor: '#A6C7ED'
}
},
scrollbar: {
barBackgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
barBorderColor: '#CCC',
buttonArrowColor: '#CCC',
buttonBackgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
buttonBorderColor: '#CCC',
rifleColor: '#FFF',
trackBackgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#000'],
[1, '#333']
]
},
trackBorderColor: '#666'
},
// special colors for some of the demo examples
legendBackgroundColor: 'rgba(48, 48, 48, 0.8)',
legendBackgroundColorSolid: 'rgb(70, 70, 70)',
dataLabelsColor: '#444',
textColor: '#E0E0E0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
var highchartsOptions = Highcharts.setOptions(Highcharts.theme);
$(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var options =
{
title: { text: '' },
xAxis: {
title: { text: 'Time (s)' },
type: 'integer',
tickPixelInterval: 60
},
yAxis: {
title: { text: 'Temperature (\xB0C)' },
tickInterval: 25,
min: 0,
max: 300
},
tooltip: {
formatter: function() {
return Highcharts.numberFormat(this.y, 0);
}
},
chart: {
2013-11-24 18:42:19 +00:00
type: 'line',
2013-11-23 21:42:23 +00:00
renderTo: 'graph_container',
animation: true,
zoomType: 'x',
marginTop: 30,
marginRight: 30,
events: {
load: function() {
var series = this.series[1];
2013-11-24 15:06:22 +00:00
ws_status.onmessage = function(e)
2013-11-23 21:42:23 +00:00
{
x = JSON.parse(e.data);
2013-11-24 14:10:48 +00:00
state = x.state;
2013-11-24 17:14:45 +00:00
$('#state').html(state);
2013-11-23 21:42:23 +00:00
2013-11-24 14:10:48 +00:00
updateProgress(parseInt(parseFloat(x.runtime)/parseFloat(x.totaltime)*100));
2013-11-24 17:54:23 +00:00
2013-11-23 21:42:23 +00:00
$('#act_temp').html(Highcharts.numberFormat(x.temperature, 0) + ' \xB0C');
2013-11-24 19:55:24 +00:00
$('#power').css("background-color", (x.power > 0.5 ? "#75890c" : "#1F1E1A") );
2013-11-24 17:54:23 +00:00
if (x.target == 0)
{
$('#target_temp').html('OFF');
}
else
{
$('#target_temp').html(Highcharts.numberFormat(x.target, 0) + ' \xB0C');
}
2013-11-24 14:10:48 +00:00
//console.log (e.data);
//console.log('Percent finished:' + perc);
if(state=="RUNNING")
{
$("#nav_start").hide();
$("#nav_stop").show();
series.addPoint([x.runtime, x.temperature], true, false);
2013-11-24 19:32:04 +00:00
left = parseInt(x.totaltime-x.runtime);
var minutes = Math.floor(left / 60);
var seconds = left - minutes * 60;
$('#eta').html(minutes+':'+ (seconds < 10 ? "0" : "") + seconds);
2013-11-24 19:55:24 +00:00
2013-11-24 19:32:04 +00:00
2013-11-24 14:10:48 +00:00
}
else
{
$("#nav_start").show();
$("#nav_stop").hide();
}
2013-11-23 21:42:23 +00:00
}
/*
var socket = io.connect('http://10.1.1.110:8080');
socket.on('sample', function (sample) {
// when a sample arrives we plot it
series.addPoint([sample.x, sample.y], true, false);
$('#act_temp').html(Highcharts.numberFormat(sample.y, 0) + ' \xB0C');
});
socket.on('error', function () {
$(document).trigger("add-alerts", [
{
'message': "No communication to control server",
'priority': 'error'
}
]);
})
// Called when the connection to the server is opened.
socket.onopen = function () {
alert("Connection with server open.");
};
// Called when the connection to the server is closed.
socket.onclose = function () {
alert("Connection with server closed; Maybe the server wasn't found, it shut down or you're behind a firewall/proxy.");
};
*/
}
},
resetZoomButton: {
position: {
align: 'right',
verticalAlign: 'top'
}
}
},
plotOptions: {
series: {
cursor: 'resize',
point: {
events: {
drag: function (e) {
$('#drag').html('Dragging <b>' + this.series.name + '</b>, <b>' + this.category + '</b> to <b>' + Highcharts.numberFormat(e.newY, 0) + '</b>');
},
drop: function () {
$('#drop').html('In <b>' + this.series.name + '</b>, <b>' + this.category + '</b> was set to <b>' + Highcharts.numberFormat(this.y, 0) + '</b>');
}
}
},
stickyTracking: false
},
},
credits: {
enabled: false
},
series: [{
name: 'Ref',
data: [
[1, 25 ],
[70, 150 ],
[180, 183 ],
[210, 230 ],
[240, 183 ],
[300, 25 ]
],
2013-11-24 19:32:04 +00:00
draggableX: false,
draggableY: false,
2013-11-23 21:42:23 +00:00
dragMinY: 0,
2013-11-24 19:32:04 +00:00
dragMaxY: 250,
marker: {
enabled: false
}
2013-11-23 21:42:23 +00:00
},
{
name: 'Act',
data: [
[0,0]
],
marker: {
enabled: false
}
}]
};
2013-11-24 14:10:48 +00:00
graph = new Highcharts.Chart(options);
2013-11-23 21:42:23 +00:00
2013-11-24 15:06:22 +00:00
2013-11-23 21:42:23 +00:00
});
</script>
</body>
</html>