diff --git a/node/flukso.js b/node/flukso.js index c3baf54..4645bdb 100644 --- a/node/flukso.js +++ b/node/flukso.js @@ -1,24 +1,12 @@ -var redis = require("redis"); var util = require('util'); var EventEmitter = require('events').EventEmitter; var http = require("http"); -var redisprefix = "flukso:"; - var Flukso = function(hostname, pathname) { var self = this; - - var redisClient = redis.createClient(); var regexp = /([0-9]+)\]\]$/; // /\(([0-9]+) hosts* up\)/; - - redisClient.on("connect", function () { - console.log("connected to redis"); - self.emit('ready'); - }); - this.pollPower = function() { - http.request({ host: hostname, path: pathname }, function(response) { var str = ''; @@ -27,39 +15,16 @@ var Flukso = function(hostname, pathname) { }); response.on('end', function () { -// console.log("http received: " + str); - var matches = regexp.exec(str); if(matches != null && matches.length == 2) { var time = Date.now(); - - redisClient.zremrangebyscore(redisprefix + 'power', "-inf", time - 7*24*60*1000); - var num = matches[1]; - - redisClient.zadd(redisprefix + 'power', time, time + "|" + num, function() { - self.emit('done', parseInt(num)); - }); + self.emit('done', parseInt(num)); } }); }).end(); }; - -// this.getHistory = function(start, end, callback) { -// -// redisClient.zrangebyscore(redisprefix + 'power', start, end, function(err, replies) { -// var data = []; -// -// replies.forEach(function (reply, i) { -// var line = reply.split('|'); -// data.push( { at: moment(parseInt(line[0])).format(), value: line[1] }); -// }); -// -// callback(data); -// }); -// }; }; util.inherits(Flukso, EventEmitter); - module.exports = Flukso; diff --git a/node/ip-poll.js b/node/ip-poll.js index fcc4699..5646861 100644 --- a/node/ip-poll.js +++ b/node/ip-poll.js @@ -10,7 +10,7 @@ var IpPoll = function(switchaddr, hostsaddr) { var redisClient = redis.createClient(); var regexp = /\(([0-9]+) hosts* up\)/; - var nmap = "nmap -n -sP -T3 "; + var nmap = "nmap -n -sP -T2 "; redisClient.on("connect", function () { console.log("connected to redis"); diff --git a/node/public/js/app.js b/node/public/js/app.js index 6bf0a99..0fc24e7 100644 --- a/node/public/js/app.js +++ b/node/public/js/app.js @@ -10,8 +10,8 @@ angular.module('roomstateapp.controllers', []). url: '/api/simple/v2' }). success(function (data, status, headers, config) { - $scope.simple = data; gpower.refresh(message.data.power); + $scope.simple = data; }). error(function (data, status, headers, config) { //$scope.name = 'Error!' @@ -20,8 +20,8 @@ angular.module('roomstateapp.controllers', []). Socket.on('sdata', function(message) { console.log("received data from server: " + message.data.names); - $scope.simple = message.data; gpower.refresh(message.data.power); + $scope.simple = message.data; }); }); @@ -75,8 +75,10 @@ gpower = new JustGage({ id: "gauge", value: 0, min: 0, - max: 15000, - title: "Power" + max: 60000, + title: " ", + label: "Watt", + showMinMax: false }); }); diff --git a/node/routes/index.js b/node/routes/index.js index 0cb4e53..a9edad3 100644 --- a/node/routes/index.js +++ b/node/routes/index.js @@ -1,10 +1,10 @@ exports.index = function (req, res) { - res.render('index', { title: 'Home', status: req.flash('status') }) + res.render('index', { title: 'Home' }) }; exports.db = function (req, res) { - res.render('database', { title: 'Manage MAC', status: req.flash('status') }) + res.render('database', { title: 'Manage MAC' }) }; exports.form = function (req, res) { diff --git a/node/views/index.jade b/node/views/index.jade index 2901733..7e8d222 100644 --- a/node/views/index.jade +++ b/node/views/index.jade @@ -2,6 +2,13 @@ extend layout block content + .intro + p + | Hier siehst du den aktuellen Status von uns. Die Daten werden vom Router und unserem Flukso + | eingesammelt. Die Anzahl der Geräte und der Status selber werden Minütlich abgefragt. Unseren + | Energieverbrauch bekommst du alle fünf Sekunden neu. Den Status "geöffnet" oder "geschlossen" + | bestimmt das Programm mit einem ping auf den Switch im Raum. + .ink-grid(ng-controller='StatusCtrl') .column-group.gutters .large-20.medium-20.small-100 @@ -22,7 +29,7 @@ block content .large-50.medium-80.small-100 - h2 Anzahl Geräte: + h2 Anzahl Geräte im LAN: #graph diff --git a/node/views/layout.jade b/node/views/layout.jade index 671514d..0178d4b 100644 --- a/node/views/layout.jade +++ b/node/views/layout.jade @@ -19,13 +19,6 @@ html(ng-app="roomstateapp") header h1 chaostreff status - .intro - p - | Hier siehst du den aktuellen Status von uns. Die Daten werden vom Router und unserem Flukso - | eingesammelt. Die Anzahl der Geräte und der Status selber werden Minütlich abgefragt. Unseren - | Energieverbrauch bekommst du alle fünf Sekunden neu. Den Status "geöffnet" oder "geschlossen" - | bestimmt das Programm mit einem ping auf den Switch im Raum. - .main-content block content