sync
This commit is contained in:
parent
efc8180221
commit
b6c6b5ce0f
22
app.js
22
app.js
|
@ -6,14 +6,14 @@ var express = require('express')
|
||||||
, cosm = require('./cosm.js')
|
, cosm = require('./cosm.js')
|
||||||
, osc = require('./osc.js');
|
, osc = require('./osc.js');
|
||||||
|
|
||||||
var cosmStreams = [84896, 84388, 70632];
|
var cosmStreams = [53146, 34606, 43573];
|
||||||
|
|
||||||
var cosmFeeds = {84896 : ["003", "004", "006"],
|
var cosmFeeds = {53146 : ["GearboxRPM", "Windspeed", "Pitch"],
|
||||||
84388 : ["Furdo", "Halo", "Gyerekszoba"],
|
34606 : ["CCChannel1,Import1", "CCSensor1,Servers2", "CCSensor2,Office3"],
|
||||||
70632 : ["househumid4", "humidity", "motion4"]};
|
43573 : ["Humidity0", "Air pressure2", "Thermo3"]};
|
||||||
|
|
||||||
var cosmClient = new cosm(cosmStreams, 'orKBBdLAKuKJU-RxqmZpZB6q0baSAKxBTVhKdjhUNkdyVT0g');
|
var cosmClient = new cosm(cosmStreams, 'orKBBdLAKuKJU-RxqmZpZB6q0baSAKxBTVhKdjhUNkdyVT0g');
|
||||||
var oscClient = new osc('localhost', 7110);
|
var oscClient = new osc('chaosc', 7110);
|
||||||
|
|
||||||
function logErrors(err, req, res, next) {
|
function logErrors(err, req, res, next) {
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
@ -35,7 +35,7 @@ function errorHandler(err, req, res, next) {
|
||||||
|
|
||||||
|
|
||||||
app.configure(function () {
|
app.configure(function () {
|
||||||
app.set('port', process.env.PORT || 3000);
|
app.set('port', process.env.PORT || 16000);
|
||||||
app.set('views', __dirname + '/views');
|
app.set('views', __dirname + '/views');
|
||||||
app.set('view engine', 'jade');
|
app.set('view engine', 'jade');
|
||||||
app.use(express.logger('dev'));
|
app.use(express.logger('dev'));
|
||||||
|
@ -73,8 +73,10 @@ server.listen(app.get('port'), function () {
|
||||||
cosmClient.on('updatevalue', function(object) {
|
cosmClient.on('updatevalue', function(object) {
|
||||||
console.log("updatevalue: " + JSON.stringify(object));
|
console.log("updatevalue: " + JSON.stringify(object));
|
||||||
oscClient.send('/cosm/' + object.stream + "/" + object.displayname, object.value);
|
oscClient.send('/cosm/' + object.stream + "/" + object.displayname, object.value);
|
||||||
if (cosmFeeds.hasOwnProperty(object.stream) && cosmFeeds[object.stream].indexOf(object.displayname) != -1)
|
if (cosmFeeds.hasOwnProperty(object.stream) && cosmFeeds[object.stream].indexOf(object.displayname) != -1) {
|
||||||
|
console.log("sending " + object.displayname);
|
||||||
io.sockets.emit('updatevalue', object);
|
io.sockets.emit('updatevalue', object);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +84,8 @@ cosmClient.on('updatevalue', function(object) {
|
||||||
cosmClient.on('changedvalue', function(object) {
|
cosmClient.on('changedvalue', function(object) {
|
||||||
console.log("changedvalue: " + JSON.stringify(object));
|
console.log("changedvalue: " + JSON.stringify(object));
|
||||||
oscClient.send('/cosm/' + object.stream + "/" + object.displayname, object.value);
|
oscClient.send('/cosm/' + object.stream + "/" + object.displayname, object.value);
|
||||||
if (cosmFeeds.hasOwnProperty(object.stream) && cosmFeeds[object.stream].indexOf(object.displayname) != -1)
|
if (cosmFeeds.hasOwnProperty(object.stream) && cosmFeeds[object.stream].indexOf(object.displayname) != -1) {
|
||||||
|
console.log("sending " + object.displayname);
|
||||||
io.sockets.emit('changedvalue', object);
|
io.sockets.emit('changedvalue', object);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: “DejaVu”;
|
||||||
|
src: url(http://dejavu-fonts.org/files/fonts/dejavu.ttf) format(”truetype”);
|
||||||
|
}
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
font-family: "DejaVu", sans-serif;
|
||||||
|
font-weight:bold;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
color: #ffcbb0;
|
color: #ffcbb0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -39,7 +45,7 @@ a {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
margin-right: 10px;*/
|
margin-right: 10px;*/
|
||||||
/* margin-bottom: 10px; */
|
/* margin-bottom: 10px; */
|
||||||
width:256px;
|
min-width:230px;
|
||||||
height: 98%;
|
height: 98%;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
border: 1px solid #7b7b7b;
|
border: 1px solid #7b7b7b;
|
||||||
|
@ -70,3 +76,20 @@ h3 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
height:1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse:collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.value {
|
||||||
|
border: 1px solid white;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.value {
|
||||||
|
text-align:left;
|
||||||
|
border-left:1px solid white;
|
||||||
|
}
|
||||||
|
|
|
@ -11,14 +11,10 @@ block content
|
||||||
div.cell
|
div.cell
|
||||||
div(id=nr, class="kasten")
|
div(id=nr, class="kasten")
|
||||||
h3 --
|
h3 --
|
||||||
h4 --
|
|
||||||
table
|
table
|
||||||
tr
|
tr
|
||||||
td Location:
|
td Location:
|
||||||
td(class="location") --
|
td(class="location") --
|
||||||
tr
|
|
||||||
td Elevation:
|
|
||||||
td(class="elevation") --
|
|
||||||
tr
|
tr
|
||||||
td Latitude:
|
td Latitude:
|
||||||
td(class="latitude") --
|
td(class="latitude") --
|
||||||
|
@ -28,6 +24,12 @@ block content
|
||||||
tr
|
tr
|
||||||
td Update:
|
td Update:
|
||||||
td(class="update") --
|
td(class="update") --
|
||||||
|
tr
|
||||||
|
td
|
||||||
|
td
|
||||||
|
tr
|
||||||
|
td(class="break")
|
||||||
|
td(class="break")
|
||||||
|
|
||||||
div.mapbox(id="map#{nr}") --
|
div.mapbox(id="map#{nr}") --
|
||||||
|
|
||||||
|
@ -67,9 +69,7 @@ block content
|
||||||
socket.on('gotstream', function(data) {
|
socket.on('gotstream', function(data) {
|
||||||
console.log("gotstream " + data.id);
|
console.log("gotstream " + data.id);
|
||||||
$("div#" + data.id + " h3").text(data.title);
|
$("div#" + data.id + " h3").text(data.title);
|
||||||
$("div#" + data.id + " h4").text(data.description);
|
|
||||||
$("div#" + data.id + " td.location").text(data.location);
|
$("div#" + data.id + " td.location").text(data.location);
|
||||||
$("div#" + data.id + " td.elevation").text(data.elevation);
|
|
||||||
$("div#" + data.id + " td.latitude").text(data.lat);
|
$("div#" + data.id + " td.latitude").text(data.lat);
|
||||||
$("div#" + data.id + " td.longitude").text(data.lon);
|
$("div#" + data.id + " td.longitude").text(data.lon);
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
|
@ -82,7 +82,7 @@ block content
|
||||||
console.dir(data);
|
console.dir(data);
|
||||||
var row = $('tr#' + data.feed).html();
|
var row = $('tr#' + data.feed).html();
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
var tmp = '<tr id="' + data.feed + '"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
var tmp = '<tr id="' + data.feed + '"class="value"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
||||||
console.log("new tmp: " + tmp);
|
console.log("new tmp: " + tmp);
|
||||||
$("div#" + data.stream + " table > tbody").append(tmp);
|
$("div#" + data.stream + " table > tbody").append(tmp);
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,12 @@ block content
|
||||||
console.dir(data);
|
console.dir(data);
|
||||||
var row = $('tr#' + data.feed).html();
|
var row = $('tr#' + data.feed).html();
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
var tmp = '<tr id="' + data.feed + '"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
var tmp = '<tr id="' + data.feed + '" class="value"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
||||||
console.log("new tmp: " + tmp);
|
console.log("new tmp: " + tmp);
|
||||||
$("div#" + data.stream + " table > tbody").append(tmp);
|
$("div#" + data.stream + " table > tbody").append(tmp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$("body").effect("highlight", {times:2}, 2000);
|
||||||
var t = 'div#' + data.stream + ' table > tbody tr#' + data.feed;
|
var t = 'div#' + data.stream + ' table > tbody tr#' + data.feed;
|
||||||
var tmp = "<td>" + data.displayname + '</td><td class="value">' + data.value + "</td>";
|
var tmp = "<td>" + data.displayname + '</td><td class="value">' + data.value + "</td>";
|
||||||
console.log("existing tmp: " + tmp);
|
console.log("existing tmp: " + tmp);
|
||||||
|
|
Loading…
Reference in New Issue