add debugging. increase concurrency of request queue
This commit is contained in:
parent
c284078db6
commit
11449b77a9
|
@ -1,4 +1,4 @@
|
||||||
var requestQueue = new Request.Queue( { concurrent: 2, stopOnFailure: false } );
|
var requestQueue = new Request.Queue( { concurrent: monitorData.length, stopOnFailure: false } );
|
||||||
|
|
||||||
function Monitor( monitorData ) {
|
function Monitor( monitorData ) {
|
||||||
this.id = monitorData.id;
|
this.id = monitorData.id;
|
||||||
|
@ -7,15 +7,18 @@ function Monitor( monitorData ) {
|
||||||
this.status = null;
|
this.status = null;
|
||||||
this.alarmState = STATE_IDLE;
|
this.alarmState = STATE_IDLE;
|
||||||
this.lastAlarmState = STATE_IDLE;
|
this.lastAlarmState = STATE_IDLE;
|
||||||
this.streamCmdParms = 'view=request&request=stream&connkey='+this.connKey;
|
this.streamCmdParms = this.server_url+'?view=request&request=stream&connkey='+this.connKey;
|
||||||
this.onclick = monitorData.onclick;
|
this.onclick = monitorData.onclick;
|
||||||
if ( auth_hash )
|
if ( auth_hash )
|
||||||
this.streamCmdParms += '&auth='+auth_hash;
|
this.streamCmdParms += '&auth='+auth_hash;
|
||||||
this.streamCmdTimer = null;
|
this.streamCmdTimer = null;
|
||||||
|
|
||||||
this.start = function( delay ) {
|
/*
|
||||||
|
this.zm_startup = function( delay ) {
|
||||||
|
console.log("Starting streamwatch for " + this.connKey );
|
||||||
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
|
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
this.setStateClass = function( element, stateClass ) {
|
this.setStateClass = function( element, stateClass ) {
|
||||||
if ( !element.hasClass( stateClass ) ) {
|
if ( !element.hasClass( stateClass ) ) {
|
||||||
|
@ -38,7 +41,10 @@ function Monitor( monitorData ) {
|
||||||
this.onFailure = function( xhr ) {
|
this.onFailure = function( xhr ) {
|
||||||
console.log('onFailure: ' + this.connKey);
|
console.log('onFailure: ' + this.connKey);
|
||||||
console.log(xhr );
|
console.log(xhr );
|
||||||
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
if ( ! requestQueue.hasNext("cmdReq"+this.id) ) {
|
||||||
|
console.log("Not requeuing because there is one already");
|
||||||
|
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
||||||
|
}
|
||||||
if ( 0 ) {
|
if ( 0 ) {
|
||||||
// Requeue, but want to wait a while.
|
// Requeue, but want to wait a while.
|
||||||
if ( this.streamCmdTimer )
|
if ( this.streamCmdTimer )
|
||||||
|
@ -47,6 +53,7 @@ function Monitor( monitorData ) {
|
||||||
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this, true );
|
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this, true );
|
||||||
requestQueue.resume();
|
requestQueue.resume();
|
||||||
}
|
}
|
||||||
|
console.log("done failure");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getStreamCmdResponse = function( respObj, respText ) {
|
this.getStreamCmdResponse = function( respObj, respText ) {
|
||||||
|
@ -134,6 +141,7 @@ function Monitor( monitorData ) {
|
||||||
console.log( this.connKey+": Resending" );
|
console.log( this.connKey+": Resending" );
|
||||||
this.streamCmdReq.cancel();
|
this.streamCmdReq.cancel();
|
||||||
}
|
}
|
||||||
|
console.log("Starting CmdQuery for " + this.connKey );
|
||||||
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
|
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,6 +156,7 @@ function Monitor( monitorData ) {
|
||||||
link: 'cancel'
|
link: 'cancel'
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
console.log("queueing for " + this.id + " " + this.connKey );
|
||||||
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +384,7 @@ function cancel_layout(button) {
|
||||||
|
|
||||||
var monitors = new Array();
|
var monitors = new Array();
|
||||||
function initPage() {
|
function initPage() {
|
||||||
|
console.log("initPage");
|
||||||
for ( var i = 0; i < monitorData.length; i++ ) {
|
for ( var i = 0; i < monitorData.length; i++ ) {
|
||||||
monitors[i] = new Monitor(monitorData[i]);
|
monitors[i] = new Monitor(monitorData[i]);
|
||||||
}
|
}
|
||||||
|
@ -384,7 +393,8 @@ function initPage() {
|
||||||
for ( var i = 0; i < monitorData.length; i++ ) {
|
for ( var i = 0; i < monitorData.length; i++ ) {
|
||||||
var delay = Math.round( (Math.random()+0.75)*statusRefreshTimeout );
|
var delay = Math.round( (Math.random()+0.75)*statusRefreshTimeout );
|
||||||
console.log("Delay for monitor " + monitorData[i].id + " is " + delay );
|
console.log("Delay for monitor " + monitorData[i].id + " is " + delay );
|
||||||
monitors[i].start(delay);
|
monitors[i].streamCmdQuery.delay( delay, monitors[i] );
|
||||||
|
//monitors[i].zm_startup(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Kick everything off
|
// Kick everything off
|
||||||
|
|
Loading…
Reference in New Issue