initial implementation of request delay balancer

10.3.x-maintenance
cTn 2014-04-12 14:55:20 +02:00
parent d18d5657a4
commit b14d26d530
3 changed files with 25 additions and 0 deletions

18
js/request_balancer.js Normal file
View File

@ -0,0 +1,18 @@
function request_delay_balancer(refresh_period) {
this.balance_to = refresh_period;
this.request_t = 0;
this.finished_t = 0;
}
request_delay_balancer.prototype.requested = function() {
this.request_t = millitime();
};
request_delay_balancer.prototype.finished = function() {
this.finished_t = millitime();
};
request_delay_balancer.prototype.estimate = function() {
var estimate = this.balance_to - (this.finished_t - this.request_t);
return (estimate > 0) ? estimate : 0;
};

View File

@ -26,6 +26,7 @@
<script type="text/javascript" src="./js/port_usage.js"></script>
<script type="text/javascript" src="./js/serial.js"></script>
<script type="text/javascript" src="./js/gui.js"></script>
<script type="text/javascript" src="./js/request_balancer.js"></script>
<script type="text/javascript" src="./js/serial_backend.js"></script>
<script type="text/javascript" src="./js/data_storage.js"></script>
<script type="text/javascript" src="./js/msp.js"></script>

View File

@ -181,6 +181,12 @@ function microtime() {
return now;
}
function millitime() {
var now = new Date().getTime();
return now;
}
/*
function add_custom_spinners() {
var spinner_element = '<div class="spinner"><div class="up"></div><div class="down"></div></div>';