LINXD-2396: Added error informations; Update to send gps from interval(min-max)
This commit is contained in:
54
src/asset.js
54
src/asset.js
@ -119,8 +119,9 @@ class Asset {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
utils.writeLog(`_getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`)
|
||||
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
utils.writeErrorLog(`ERROR_API | _checkGroupToJoin`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -143,7 +144,7 @@ class Asset {
|
||||
return this._getGroupsFromApi(callback);
|
||||
} else {
|
||||
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
utils.writeErrorLog(`ERROR_API | _getDataFromApi`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -192,7 +193,7 @@ class Asset {
|
||||
return callback();
|
||||
} else {
|
||||
utils.writeLog(`Error getting informations about asset ${this.id}`, error);
|
||||
utils.writeErrorLog(`ERROR_API`);
|
||||
utils.writeErrorLog(`ERROR_API | _getGroupsFromApi`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
@ -211,12 +212,12 @@ class Asset {
|
||||
|
||||
hub.on('connect_timeout', () => {
|
||||
utils.writeLog(`Asset ${this.id} connect_timeout from HUB`);
|
||||
utils.writeErrorLog(`ERROR_HUB`);
|
||||
utils.writeErrorLog(`ERROR_HUB | _connectToHub`);
|
||||
});
|
||||
|
||||
hub.on('connect_error', () => {
|
||||
utils.writeLog(`Asset ${this.id} connect_error from HUB`);
|
||||
utils.writeErrorLog(`ERROR_HUB`);
|
||||
utils.writeErrorLog(`ERROR_HUB | _connectToHub`);
|
||||
});
|
||||
|
||||
hub.once('connect', () => {
|
||||
@ -256,8 +257,8 @@ class Asset {
|
||||
}
|
||||
|
||||
_connectToMurmur(callback) {
|
||||
!this.group_id && return callback();
|
||||
|
||||
if (!this.group_id) { return callback(); }
|
||||
|
||||
console.log(`Asset ${this.id} connecting to Murmur`);
|
||||
const murmurConnectionDetails = {
|
||||
mumbleHost: this.mumbleHost,
|
||||
@ -268,13 +269,12 @@ class Asset {
|
||||
this.mumble = new Mumble(this.id, murmurConnectionDetails, (err) => {
|
||||
if (err) {
|
||||
utils.writeLog(`Asset ${this.id} Murmur connection error`, err);
|
||||
utils.writeErrorLog(`ERROR_MURMUR`);
|
||||
utils.writeErrorLog(`ERROR_MURMUR | _connectToMurmur`);
|
||||
return callback(err);
|
||||
} else {
|
||||
// return callback();
|
||||
setTimeout(()=> {
|
||||
return callback();
|
||||
}, 400);
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -293,13 +293,10 @@ class Asset {
|
||||
utils.writeLog(`Asset ${this.id} audio registered`);
|
||||
return callback();
|
||||
} else {
|
||||
console.log('_register--------------------')
|
||||
console.log('error---', error)
|
||||
// console.log('response---', response)
|
||||
console.log('body---', body)
|
||||
// utils.writeLog(`Asset ${this.id} audio registered error`, error);
|
||||
// utils.writeErrorLog(`ERROR_API`);
|
||||
// return callback(error);
|
||||
console.log('body', body)
|
||||
utils.writeLog(`Asset ${this.id} audio registered error`, error);
|
||||
utils.writeErrorLog(`ERROR_AUDIO | _register`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -338,13 +335,9 @@ class Asset {
|
||||
if (callback) return callback('Cannot send group-monitoring: Hub not connected');
|
||||
}
|
||||
} else {
|
||||
console.log('_moveToChannel--------------------')
|
||||
console.log('error---', error)
|
||||
// console.log('response---', response)
|
||||
console.log('body---', body)
|
||||
// utils.writeLog(`Asset ${this.id} audio enter group error`, error);
|
||||
// utils.writeErrorLog(`ERROR_API`);
|
||||
// return callback(error);
|
||||
utils.writeLog(`Asset ${this.id} audio enter group error`, error);
|
||||
utils.writeErrorLog(`ERROR_AUDIO | _moveToChannel`);
|
||||
return callback(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -396,7 +389,7 @@ class Asset {
|
||||
}
|
||||
} else {
|
||||
utils.writeLog(`Error getting record for asset ${this.id} | ${error}`);
|
||||
utils.writeErrorLog(`ERROR_RECORDER`);
|
||||
utils.writeErrorLog(`ERROR_RECORDER | _getRecord`);
|
||||
}
|
||||
let assetIds = configs.assets.ids;
|
||||
|
||||
@ -544,6 +537,15 @@ class Asset {
|
||||
if (hub && hub.connected) {
|
||||
let lat = this.configs.settings.gps_lat_start_point;
|
||||
let lng = this.configs.settings.gps_lng_start_point;
|
||||
const max = this.configs.settings.gps_max_interval;
|
||||
const min = this.configs.settings.gps_min_interval;
|
||||
|
||||
let interval = null;
|
||||
if (!this.configs.settings.gps_report_interval) {
|
||||
interval = Math.floor(Math.random() * (max - min + 1) + min);
|
||||
} else {
|
||||
interval = this.configs.settings.gps_report_interval;
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
const now = +new Date();
|
||||
@ -574,7 +576,7 @@ class Asset {
|
||||
});
|
||||
}, 11000);
|
||||
}
|
||||
}, this.configs.settings.gps_report_interval);
|
||||
}, interval);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,10 @@ class Mumble {
|
||||
this.mumblePort = murmurConnectionDetails.mumblePort;
|
||||
this.murmurUser = murmurConnectionDetails.murmurUser;
|
||||
this.murmurPassword = murmurConnectionDetails.murmurPassword;
|
||||
console.log('mumbleHost', this.mumbleHost)
|
||||
console.log('mumblePort', this.mumblePort)
|
||||
console.log('murmurUser', this.murmurUser)
|
||||
console.log('murmurPassword', this.murmurPassword)
|
||||
// console.log('mumbleHost', this.mumbleHost)
|
||||
// console.log('mumblePort', this.mumblePort)
|
||||
// console.log('murmurUser', this.murmurUser)
|
||||
// console.log('murmurPassword', this.murmurPassword)
|
||||
|
||||
this._createCertificatesForUser(id, () => {
|
||||
this._makeMumbleConnection(id, this.mumblePort, this.mumbleHost, id, this.murmurPassword, connectedCallback);
|
||||
|
@ -36,19 +36,11 @@ class Simulator {
|
||||
_start() {
|
||||
const settings = this.configs.settings;
|
||||
|
||||
// this.assetIds.forEach((id, i) => {
|
||||
this.assets.forEach((asset, i) => {
|
||||
let delay_between_clients = 500;
|
||||
if(settings.hasOwnProperty('delay_between_clients')) {
|
||||
delay_between_clients = parseInt(settings.delay_between_clients, 10);
|
||||
}
|
||||
console.log('asset_id', asset.asset_id, i * delay_between_clients+'ms')
|
||||
|
||||
delay_between_clients = this._getRandomInt(delay_between_clients);
|
||||
console.log('asset_id', asset.asset_id, i * settings.delay_between_clients + 'ms');
|
||||
setTimeout(() => {
|
||||
new Asset(asset, this.configs, this.token);
|
||||
// console.log('id, this.configs, this.token', id, this.configs, this.token)
|
||||
}, i * delay_between_clients);
|
||||
}, i * settings.delay_between_clients);
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user