diff --git a/config.js b/config.js
index 55c2ab8..ce04415 100644
--- a/config.js
+++ b/config.js
@@ -11,7 +11,7 @@ var config = {
BACKEND_SOCKET: "./backend/rtbw.sock",
BUFFER_PURGE_TIME: 1800000, //30 minutes
- SUPERBUFFER_PURGE_TIME: 43200000 //12 hours
+ SUPERBUFFER_SIZE: 24
};
module.exports = config;
diff --git a/graphBuffer.js b/graphBuffer.js
index 9a1829c..7ddcdf8 100644
--- a/graphBuffer.js
+++ b/graphBuffer.js
@@ -2,14 +2,20 @@ const Cycle = require("./cycle").Cycle;
const logger = require("./logger");
class CycleBuffer {
- constructor(purgeTime) {
+ constructor(purgeTime, fixed=false) {
this.time = purgeTime;
this.buffer=[];
var th = this;
this.onclear = function(sp) {};
- this.inter = setInterval(function() {
- th.purge();
- }, this.time);
+
+ if(fixed) {
+ this.fixed=true;
+ }
+ else {
+ this.inter = setInterval(function() {
+ th.purge();
+ }, this.time);
+ }
}
purge()
@@ -20,6 +26,8 @@ class CycleBuffer {
add(cycle) {
this.buffer.push(cycle);
+ if(this.fixed && this.buffer.length>=this.time)
+ this.buffer.shift();
}
all() {
@@ -31,7 +39,8 @@ class CycleBuffer {
return ret;
}
close() {
- clearInterval(this.inter);
+ if(this.inter)
+ clearInterval(this.inter);
this.buffer.length=0;
}
}
diff --git a/main.js b/main.js
index 5f82465..c4e46e8 100644
--- a/main.js
+++ b/main.js
@@ -75,7 +75,7 @@ var allTime = new _cycle.Cycle();
var allTimeAverage = new _cycle.Cycle();
var allTimeAverageN = 0;
var buffer = new CycleBuffer(config.BUFFER_PURGE_TIME);
-var superbuffer = new CycleBuffer(config.SUPERBUFFER_PURGE_TIME);
+var superbuffer = new CycleBuffer(config.SUPERBUFFER_SIZE, true);
var beInfo = null;
var upSince = new Date();
@@ -96,7 +96,7 @@ superbuffer.onclear = function(bu) {
};
logger.log("Buffer set to clear every "+(config.BUFFER_PURGE_TIME/1000/60)+" minutes");
-logger.log("Superbuffer set to clear every "+(config.SUPERBUFFER_PURGE_TIME/1000/60)+" minutes");
+logger.log("Superbuffer set to fill at "+(config.SUPERBUFFER_SIZE)+" entries");
process.execFile(config.PYTHON_EXECUTABLE, [config.RTBWCTL_FILENAME, config.BACKEND_SOCKET, "info"], function(error,stdout,stderr) {
@@ -128,7 +128,7 @@ var server = http.createServer(function(req, res) {
res.end(JSON.stringify({
interval: config.POLL_INTERVAL,
purgeInterval: config.BUFFER_PURGE_TIME,
- superPurgeInterval: config.SUPERBUFFER_PURGE_TIME,
+ superPurgeInterval: config.SUPERBUFFER_SIZE,
backendInterval: beInfo.timeout,
board: beInfo.board,
upSince: upSince
@@ -213,10 +213,6 @@ wss.on('request', function(req) { //why isn't this getting called?
});
wss.on('connection', function (ws) {
-
- /*ws.on('message', function (message) {
- ws.send("Received: " + message);
- });*/
var f = function(cycle) {
ws.send(JSON.stringify({type: "cycle", data: cycle}));
};
diff --git a/www/index.html b/www/index.html
index 492fb17..c6c4092 100644
--- a/www/index.html
+++ b/www/index.html
@@ -19,7 +19,7 @@
Cycle interval:
Archiver interval:
Server buffer purge interval:
- Server aggregate buffer purge interval:
+ Server aggregate buffer max size: