Skip to content
Browse files

robusted logging/viewing

  • Loading branch information...
1 parent 0605eca commit 09e6cdf9eac73f705dfff1f89d93640814aae3d6 @dansteingart committed Jan 25, 2012
Showing with 14 additions and 10 deletions.
  1. +7 −1 NodeJS/Ardustat_Control/expresserver.js
  2. +7 −9 NodeJS/Ardustat_Viewer/view_server.js
View
8 NodeJS/Ardustat_Control/expresserver.js
@@ -649,7 +649,7 @@ function toArd(command,value)
}
everyxlogcounter = 0
-
+biglogger = 0
serialPort.on("data", function (data) {
if (data.search("GO")>-1)
{
@@ -684,6 +684,8 @@ serialPort.on("data", function (data) {
everyxlogcounter++
if (everyxlogcounter > everyxlog)
{
+ foo['seq_no'] = biglogger
+ biglogger++;
db.collection(atafile).insert(foo)
db.collection(central_info).update({filename:to_central_info.filename},to_central_info,{upsert:true});
everyxlogcounter = 0
@@ -692,6 +694,10 @@ serialPort.on("data", function (data) {
//exec("echo '"+JSON.stringify(foo)+"' >> data/"+datafile);
}
+ else
+ {
+ biglogger = 0
+ }
foo['logger'] = logger
foo['datafile'] = datafile
io.sockets.emit('new_data',{'ardudata':foo} )
View
16 NodeJS/Ardustat_Viewer/view_server.js
@@ -121,20 +121,18 @@ function getStuff(req,res)
db.collection(collection).find(q,f).limit(l).sort(s).count(function(err,count)
{
console.log(count)
-
- if (count > 1000)
+ max_docsish = 500
+ if (count > max_docsish)
{
- ranger = count/1000
- if (q['time'] != undefined) q['time']['$mod'] = [ranger,0]
- else
- {
- q['time'] = {}
- q['time']['$mod'] = [ranger,0]
- }
+ ranger = Math.floor(parseFloat(count)/parseFloat(max_docsish))
+ q['seq_no'] = {}
+ q['seq_no']['$mod'] = [ranger,0]
+
}
db.collection(collection).find(q,f).limit(l).sort(s).toArray(function(err,data)
{
+ console.log(data.length)
res.send({collect:collection,data:data})
})
})

0 comments on commit 09e6cdf

Please sign in to comment.
Something went wrong with that request. Please try again.