fx for changed values, using correct port for chaosc, feed whitelist per stream
This commit is contained in:
parent
a7119749fc
commit
47f44234ec
14
app.js
14
app.js
|
@ -6,10 +6,14 @@ var express = require('express')
|
||||||
, cosm = require('./cosm.js')
|
, cosm = require('./cosm.js')
|
||||||
, osc = require('./osc.js');
|
, osc = require('./osc.js');
|
||||||
|
|
||||||
var cosmStreams = [97325, 84896, 84388, 70632 ];
|
var cosmStreams = [84896, 84388, 70632];
|
||||||
|
|
||||||
|
var cosmFeeds = {84896 : ["003", "004", "006"],
|
||||||
|
84388 : ["Furdo", "Halo", "Gyerekszoba"],
|
||||||
|
70632 : ["househumid4", "humidity", "motion4"]};
|
||||||
|
|
||||||
var cosmClient = new cosm(cosmStreams, 'orKBBdLAKuKJU-RxqmZpZB6q0baSAKxBTVhKdjhUNkdyVT0g');
|
var cosmClient = new cosm(cosmStreams, 'orKBBdLAKuKJU-RxqmZpZB6q0baSAKxBTVhKdjhUNkdyVT0g');
|
||||||
var oscClient = new osc('localhost', 8000);
|
var oscClient = new osc('localhost', 7110);
|
||||||
|
|
||||||
function logErrors(err, req, res, next) {
|
function logErrors(err, req, res, next) {
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
@ -69,7 +73,8 @@ 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);
|
||||||
io.sockets.emit('updatevalue', object);
|
if (cosmFeeds.hasOwnProperty(object.stream) && cosmFeeds[object.stream].indexOf(object.displayname) != -1)
|
||||||
|
io.sockets.emit('updatevalue', object);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,5 +82,6 @@ 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);
|
||||||
io.sockets.emit('changedvalue', object);
|
if (cosmFeeds.hasOwnProperty(object.stream) && cosmFeeds[object.stream].indexOf(object.displayname) != -1)
|
||||||
|
io.sockets.emit('changedvalue', object);
|
||||||
});
|
});
|
5
cosm.js
5
cosm.js
|
@ -51,8 +51,9 @@ function Cosm(streams, key) {
|
||||||
|
|
||||||
var address = obj.id + ":" + dataStream.id;
|
var address = obj.id + ":" + dataStream.id;
|
||||||
|
|
||||||
console.log(recentvalues);
|
console.log(recentvalues[address] + " " + currentValue);
|
||||||
if(recentvalues[address] != currentValue) {
|
console.log(typeof(recentvalues[address]) + " " + typeof(currentValue));
|
||||||
|
if(recentvalues[address] !== currentValue) {
|
||||||
self.emit('changedvalue', object);
|
self.emit('changedvalue', object);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -34,8 +34,13 @@ a {
|
||||||
|
|
||||||
.kasten {
|
.kasten {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 10px;
|
margin: 5px;
|
||||||
height: 90%;
|
/*margin-right: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-right: 10px;*/
|
||||||
|
/* margin-bottom: 10px; */
|
||||||
|
width:256px;
|
||||||
|
height: 98%;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
border: 1px solid #7b7b7b;
|
border: 1px solid #7b7b7b;
|
||||||
-webkit-border-radius: 5px;
|
-webkit-border-radius: 5px;
|
||||||
|
@ -45,11 +50,12 @@ a {
|
||||||
|
|
||||||
div.mapbox {
|
div.mapbox {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
width:270px;
|
width:236px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
/* margin-top:20px; */
|
||||||
position:absolute;
|
position:absolute;
|
||||||
bottom:10%;
|
bottom:20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kasten img {
|
.kasten img {
|
||||||
|
|
|
@ -31,10 +31,6 @@ block content
|
||||||
|
|
||||||
div.mapbox(id="map#{nr}") --
|
div.mapbox(id="map#{nr}") --
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
script(type="text/javascript",src="http://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyDZ5gUZumNEZOHyRLs4HWJEJ-mDeEkWInU")
|
|
||||||
|
|
||||||
script(type="text/javascript")
|
script(type="text/javascript")
|
||||||
//var streams;
|
//var streams;
|
||||||
//var stream;
|
//var stream;
|
||||||
|
@ -82,23 +78,37 @@ block content
|
||||||
});
|
});
|
||||||
|
|
||||||
function add_data(data) {
|
function add_data(data) {
|
||||||
console.log("changedvalue");
|
console.log("add_data");
|
||||||
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>" + data.value + "</td></tr>";
|
var tmp = '<tr id="' + data.feed + '"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
||||||
|
console.log("new tmp: " + tmp);
|
||||||
|
$("div#" + data.stream + " table > tbody").append(tmp);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function update_data(data) {
|
||||||
|
console.log("update_data");
|
||||||
|
console.dir(data);
|
||||||
|
var row = $('tr#' + data.feed).html();
|
||||||
|
if (row === undefined) {
|
||||||
|
var tmp = '<tr id="' + data.feed + '"><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 {
|
||||||
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>" + 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);
|
||||||
$(t).html(tmp);
|
$(t).html(tmp);
|
||||||
|
var f = $("tr#" + data.feed + " .value");
|
||||||
|
console.dir(f);
|
||||||
|
f.effect("pulsate", { times:3 }, 2000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.on('changedvalue', add_data);
|
socket.on('changedvalue', update_data);
|
||||||
|
|
||||||
socket.on('updatevalue', add_data);
|
socket.on('updatevalue', add_data);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ html
|
||||||
meta(name='viewport', content='width=device-width, initial-scale=1.0')
|
meta(name='viewport', content='width=device-width, initial-scale=1.0')
|
||||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||||
script(type="text/javascript",src="/javascripts/jquery-1.9.0.min.js")
|
script(type="text/javascript",src="/javascripts/jquery-1.9.0.min.js")
|
||||||
|
script(type="text/javascript",src="/javascripts/jquery-ui-1.10.1.custom.min.js")
|
||||||
|
script(type="text/javascript",src="http://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyDZ5gUZumNEZOHyRLs4HWJEJ-mDeEkWInU")
|
||||||
block head
|
block head
|
||||||
|
|
||||||
body
|
body
|
||||||
|
|
Loading…
Reference in New Issue