Mercurial > hg > nodescore
changeset 53:a0ae699ac444
chronometer no long increments but now compares start time with current
time
author | root <root@beaglebone.(none)> |
---|---|
date | Sun, 14 Oct 2012 00:26:42 +0000 |
parents | a79555d4ad18 |
children | 66bf613fb818 |
files | chronometer.js nodescore nodescore.js |
diffstat | 3 files changed, 24 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/chronometer.js Sun Oct 14 00:25:26 2012 +0000 +++ b/chronometer.js Sun Oct 14 00:26:42 2012 +0000 @@ -31,11 +31,11 @@ chron = pad(hours) +":"+pad(mins)+ ':'+ pad(seconds)+ ":"+ zecsec chronsec = pad(hours) +":"+pad(mins)+ ':'+ pad(seconds) if ( divisor !== 1000 ){ - return chronsec + return chron } - else { return chron } + else { return chronsec } }; exports.chronometer =chronometer; exports.xdateTime = xdateTime; -exports.zeroChron = zeroChron; \ No newline at end of file +exports.zeroChron = zeroChron;
--- a/nodescore Sun Oct 14 00:25:26 2012 +0000 +++ b/nodescore Sun Oct 14 00:26:42 2012 +0000 @@ -9,6 +9,8 @@ # nodescore@kiben.net # nodescore.kiben.net +export NODE_PATH=${NODE_PATH}:/home/root/node_modules/:/usr/share/nodescore/ + if [ "$1" = "home" ] then SERVER='192.168.1.77:8889' @@ -16,7 +18,7 @@ SERVER='http://nodescore.kiben.net:8889' fi -BASEDIR='www/m' +BASEDIR='/usr/share/nodescore/www/m' PROJECT='seta' THUMBPATH=$BASEDIR/thumbs @@ -26,6 +28,6 @@ fi killall node; -supervisor nodescore.js & +nice -n -20 supervisor /usr/share/nodescore/nodescore.js & sleep 2; sh ss2thumb.sh $PROJECT $SERVER;
--- a/nodescore.js Sun Oct 14 00:25:26 2012 +0000 +++ b/nodescore.js Sun Oct 14 00:26:42 2012 +0000 @@ -10,13 +10,13 @@ var sio = require('socket.io') , http = require('http') -, ch = require('./chronometer') +, ch = require('chronometer') , fs = require('fs') , static = require('node-static'); // run webserver serving static html //////////////////////////////////////////// -var clientFiles = new static.Server('./www'); +var clientFiles = new static.Server('/usr/share/nodescore/www'); var httpServer = http.createServer( function(request, response) { request.addListener('end', function () { @@ -128,13 +128,22 @@ function chronCtrl (state,interval){ console.log("=========================== chronstate=" + chronstate) if (state==1){ + var date = new Date() + var starttime = new Date().getTime() / 1000; + //var interval = 1020 - date.getMilliseconds(); xstopwatch = setInterval(function () { - c = ch.chronometer(interval/100) - //cz = ch.chronometer(interval/100) - socket.broadcast.emit('chronFromServer', c) - socket.emit('chronFromServer', c) - }, interval) + var nowtime = new Date().getTime() / 1000; + now = nowtime-starttime + hours = parseInt( now / 3600 ) % 24; + minutes = parseInt( now / 60 ) % 60; + seconds = parseInt(now % 60); + milliseconds = Math.floor((now-seconds)*10)%60; + time = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds) + "."+milliseconds; + console.log(time) + socket.broadcast.emit('chronFromServer', time) + socket.emit('chronFromServer', time) + }, 200) } if (state==0) { clearInterval(xstopwatch); @@ -167,7 +176,7 @@ // magic square sequencer //////////////////////////////////////////// // var score = require('./score'); -// var c = require('./chronometer'); +// var c = require('/usr/share/nodescore/www/m/js/chronometer'); // var mm = score.mm var sequencerState = 0;