diff --git a/app.js b/app.js index b7fefaa..178607c 100644 --- a/app.js +++ b/app.js @@ -6,10 +6,14 @@ var express = require('express') , cosm = require('./cosm.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 oscClient = new osc('localhost', 8000); +var oscClient = new osc('localhost', 7110); function logErrors(err, req, res, next) { console.error(err.stack); @@ -69,7 +73,8 @@ server.listen(app.get('port'), function () { cosmClient.on('updatevalue', function(object) { console.log("updatevalue: " + JSON.stringify(object)); 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) { console.log("changedvalue: " + JSON.stringify(object)); 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); }); \ No newline at end of file diff --git a/cosm.js b/cosm.js index 8bfedfb..425faf8 100644 --- a/cosm.js +++ b/cosm.js @@ -51,8 +51,9 @@ function Cosm(streams, key) { var address = obj.id + ":" + dataStream.id; - console.log(recentvalues); - if(recentvalues[address] != currentValue) { + console.log(recentvalues[address] + " " + currentValue); + console.log(typeof(recentvalues[address]) + " " + typeof(currentValue)); + if(recentvalues[address] !== currentValue) { self.emit('changedvalue', object); } else diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index c9a9bed..47a84e0 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -34,8 +34,13 @@ a { .kasten { padding: 10px; - margin: 10px; - height: 90%; + margin: 5px; + /*margin-right: 10px; + margin-right: 10px; + margin-right: 10px;*/ +/* margin-bottom: 10px; */ + width:256px; + height: 98%; background-color: #444; border: 1px solid #7b7b7b; -webkit-border-radius: 5px; @@ -45,11 +50,12 @@ a { div.mapbox { height: 150px; - width:270px; + width:236px; margin-left: auto; margin-right: auto; +/* margin-top:20px; */ position:absolute; - bottom:10%; + bottom:20px; } .kasten img { diff --git a/views/index.jade b/views/index.jade index be1d97c..7af0c7f 100644 --- a/views/index.jade +++ b/views/index.jade @@ -31,10 +31,6 @@ block content 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") //var streams; //var stream; @@ -82,23 +78,37 @@ block content }); function add_data(data) { - console.log("changedvalue"); + console.log("add_data"); console.dir(data); var row = $('tr#' + data.feed).html(); if (row === undefined) { - var tmp = '