LINXD-2396: Get Hub address from asset configuration; Take default main group if not specified in config; Update config to not declare hub address and voice server #6

Merged
sergiu merged 4 commits from LINXD-2396-simulator-improvements into master 2023-05-10 07:18:03 +00:00
4 changed files with 489 additions and 50 deletions
Showing only changes of commit faa8e8099e - Show all commits

View File

@ -3,31 +3,476 @@ name = 'dev'
[api] [api]
port = '' port = ''
host = 'dev.linx.safemobile.com/api' host = 'node.dev.linx.safemobile.com/api'
use_secure = true use_secure = true
accept_untrusted_certs = true accept_untrusted_certs = true
[settings] [settings]
max_fails = 3 max_fails = 3
send_group_monitoring_before_each_call = 'true' send_group_monitoring_before_each_call = 'false'
gps_report_interval = 1000 # The interval in which the GPS is sent gps_report_interval = ''
gps_min_interval = 1000
gps_max_interval = 10000
gps_lat_start_point = 46.217802 gps_lat_start_point = 46.217802
gps_lng_start_point = 24.776126 gps_lng_start_point = 24.776126
delay_between_clients = 300 delay_between_clients = 500
testing_duration = 40 # seconds testing_duration = 240 # seconds
# group 1 / 1 send / 10 listen
[[assets]] [[assets]]
asset_id = 63 asset_id = 7516
group_id = 1 group_id = 2561
generate_voice = true generate_voice = true
generate_gps = true generate_gps = true
[[assets]] [[assets]]
asset_id = 64 asset_id = 7517
group_id = 1 group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7518
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7519
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7520
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7521
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7522
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7523
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7524
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7525
group_id = 2561
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7526
group_id = 2561
generate_voice = false
generate_gps = true
# group 2 / 1 send / 10 listen
[[assets]]
asset_id = 7536
group_id = 2560
generate_voice = true
generate_gps = true
[[assets]]
asset_id = 7537
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7538
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7539
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7540
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7541
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7542
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7543
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7544
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7545
group_id = 2560
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7546
group_id = 2560
generate_voice = false
generate_gps = true
# group 3 / 1 send / 10 listen
[[assets]]
asset_id = 7556
group_id = 2559
generate_voice = true
generate_gps = true
[[assets]]
asset_id = 7557
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7558
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7559
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7560
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7561
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7562
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7563
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7564
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7565
group_id = 2559
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7566
group_id = 2559
generate_voice = false
generate_gps = true
# group 4 / 1 send / 10 listen
[[assets]]
asset_id = 7576
group_id = 2558
generate_voice = true
generate_gps = true
[[assets]]
asset_id = 7577
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7578
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7579
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7580
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7581
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7582
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7583
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7584
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7585
group_id = 2558
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7586
group_id = 2558
generate_voice = false
generate_gps = true
# group 5 / 1 send / 10 listen
# group 6 / 1 send / 10 listen
# group 7 / 1 send / 10 listen
# group 8 / 1 send / 10 listen
# group 9 / 1 send / 10 listen
# group 10 / 1 send / 10 listen
[[assets]]
asset_id = 7715
group_id = 2552
generate_voice = true
generate_gps = true
[[assets]]
asset_id = 7714
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7713
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7712
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7711
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7710
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7709
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7708
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7707
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7706
group_id = 2552
generate_voice = false
generate_gps = true
[[assets]]
asset_id = 7705
group_id = 2552
generate_voice = false generate_voice = false
generate_gps = true generate_gps = true
[[assets]]
asset_id = 7796
group_id = 2557
[[assets]]
asset_id = 7797
group_id = 2557
[[assets]]
asset_id = 7798
group_id = 2557
[[assets]]
asset_id = 7799
group_id = 2557
[[assets]]
asset_id = 7800
group_id = 2557
[[assets]]
asset_id = 7801
group_id = 2557
[[assets]]
asset_id = 7802
group_id = 2557
[[assets]]
asset_id = 7803
group_id = 2557
[[assets]]
asset_id = 7804
group_id = 2557
[[assets]]
asset_id = 7805
group_id = 2557
[[assets]]
asset_id = 7806
group_id = 2557
[[assets]]
asset_id = 7817
group_id = 2556
[[assets]]
asset_id = 7818
group_id = 2556
[[assets]]
asset_id = 7819
group_id = 2556
[[assets]]
asset_id = 7820
group_id = 2556
[[assets]]
asset_id = 7821
group_id = 2556
[[assets]]
asset_id = 7822
group_id = 2556
[[assets]]
asset_id = 7823
group_id = 2556
[[assets]]
asset_id = 7824
group_id = 2556
[[assets]]
asset_id = 7825
group_id = 2556
[[assets]]
asset_id = 7826
group_id = 2556
[[assets]]
asset_id = 7827
group_id = 2556
[sounds] [sounds]
tracks = ['1.mp3','2.mp3','3.mp3','4.mp3','5.mp3','6.mp3','7.mp3','8.mp3','9.mp3','10.mp3','11.mp3','12.mp3','13.mp3','14.mp3','15.mp3','16.mp3','17.mp3','18.mp3','19.mp3'] tracks = ['1.mp3','2.mp3','3.mp3','4.mp3','5.mp3','6.mp3','7.mp3','8.mp3','9.mp3','10.mp3','11.mp3','12.mp3','13.mp3','14.mp3','15.mp3','16.mp3','17.mp3','18.mp3','19.mp3']

View File

@ -119,8 +119,9 @@ class Asset {
return; return;
} }
} else { } else {
utils.writeLog(`_getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`)
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
utils.writeErrorLog(`ERROR_API`); utils.writeErrorLog(`ERROR_API | _checkGroupToJoin`);
return callback(error); return callback(error);
} }
} }
@ -143,7 +144,7 @@ class Asset {
return this._getGroupsFromApi(callback); return this._getGroupsFromApi(callback);
} else { } else {
utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); utils.writeLog(`ERROR getting informations about asset ${this.id}`, error);
utils.writeErrorLog(`ERROR_API`); utils.writeErrorLog(`ERROR_API | _getDataFromApi`);
return callback(error); return callback(error);
} }
} }
@ -192,7 +193,7 @@ class Asset {
return callback(); return callback();
} else { } else {
utils.writeLog(`Error getting informations about asset ${this.id}`, error); utils.writeLog(`Error getting informations about asset ${this.id}`, error);
utils.writeErrorLog(`ERROR_API`); utils.writeErrorLog(`ERROR_API | _getGroupsFromApi`);
return callback(error); return callback(error);
} }
} }
@ -211,12 +212,12 @@ class Asset {
hub.on('connect_timeout', () => { hub.on('connect_timeout', () => {
utils.writeLog(`Asset ${this.id} connect_timeout from HUB`); utils.writeLog(`Asset ${this.id} connect_timeout from HUB`);
utils.writeErrorLog(`ERROR_HUB`); utils.writeErrorLog(`ERROR_HUB | _connectToHub`);
}); });
hub.on('connect_error', () => { hub.on('connect_error', () => {
utils.writeLog(`Asset ${this.id} connect_error from HUB`); utils.writeLog(`Asset ${this.id} connect_error from HUB`);
utils.writeErrorLog(`ERROR_HUB`); utils.writeErrorLog(`ERROR_HUB | _connectToHub`);
}); });
hub.once('connect', () => { hub.once('connect', () => {
@ -256,8 +257,8 @@ class Asset {
} }
_connectToMurmur(callback) { _connectToMurmur(callback) {
!this.group_id && return callback(); if (!this.group_id) { return callback(); }
console.log(`Asset ${this.id} connecting to Murmur`); console.log(`Asset ${this.id} connecting to Murmur`);
const murmurConnectionDetails = { const murmurConnectionDetails = {
mumbleHost: this.mumbleHost, mumbleHost: this.mumbleHost,
@ -268,13 +269,12 @@ class Asset {
this.mumble = new Mumble(this.id, murmurConnectionDetails, (err) => { this.mumble = new Mumble(this.id, murmurConnectionDetails, (err) => {
if (err) { if (err) {
utils.writeLog(`Asset ${this.id} Murmur connection error`, err); utils.writeLog(`Asset ${this.id} Murmur connection error`, err);
utils.writeErrorLog(`ERROR_MURMUR`); utils.writeErrorLog(`ERROR_MURMUR | _connectToMurmur`);
return callback(err); return callback(err);
} else { } else {
// return callback();
setTimeout(()=> { setTimeout(()=> {
return callback(); return callback();
}, 400); }, 500);
} }
}); });
} }
@ -293,13 +293,10 @@ class Asset {
utils.writeLog(`Asset ${this.id} audio registered`); utils.writeLog(`Asset ${this.id} audio registered`);
return callback(); return callback();
} else { } else {
console.log('_register--------------------') console.log('body', body)
console.log('error---', error) utils.writeLog(`Asset ${this.id} audio registered error`, error);
// console.log('response---', response) utils.writeErrorLog(`ERROR_AUDIO | _register`);
console.log('body---', body) return callback(error);
// utils.writeLog(`Asset ${this.id} audio registered error`, error);
// utils.writeErrorLog(`ERROR_API`);
// return callback(error);
} }
} }
); );
@ -338,13 +335,9 @@ class Asset {
if (callback) return callback('Cannot send group-monitoring: Hub not connected'); if (callback) return callback('Cannot send group-monitoring: Hub not connected');
} }
} else { } else {
console.log('_moveToChannel--------------------') utils.writeLog(`Asset ${this.id} audio enter group error`, error);
console.log('error---', error) utils.writeErrorLog(`ERROR_AUDIO | _moveToChannel`);
// console.log('response---', response) return callback(error);
console.log('body---', body)
// utils.writeLog(`Asset ${this.id} audio enter group error`, error);
// utils.writeErrorLog(`ERROR_API`);
// return callback(error);
} }
} }
); );
@ -396,7 +389,7 @@ class Asset {
} }
} else { } else {
utils.writeLog(`Error getting record for asset ${this.id} | ${error}`); utils.writeLog(`Error getting record for asset ${this.id} | ${error}`);
utils.writeErrorLog(`ERROR_RECORDER`); utils.writeErrorLog(`ERROR_RECORDER | _getRecord`);
} }
let assetIds = configs.assets.ids; let assetIds = configs.assets.ids;
@ -544,6 +537,15 @@ class Asset {
if (hub && hub.connected) { if (hub && hub.connected) {
let lat = this.configs.settings.gps_lat_start_point; let lat = this.configs.settings.gps_lat_start_point;
let lng = this.configs.settings.gps_lng_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(() => { setInterval(() => {
const now = +new Date(); const now = +new Date();
@ -574,7 +576,7 @@ class Asset {
}); });
}, 11000); }, 11000);
} }
}, this.configs.settings.gps_report_interval); }, interval);
} }
} }

View File

@ -17,10 +17,10 @@ class Mumble {
this.mumblePort = murmurConnectionDetails.mumblePort; this.mumblePort = murmurConnectionDetails.mumblePort;
this.murmurUser = murmurConnectionDetails.murmurUser; this.murmurUser = murmurConnectionDetails.murmurUser;
this.murmurPassword = murmurConnectionDetails.murmurPassword; this.murmurPassword = murmurConnectionDetails.murmurPassword;
console.log('mumbleHost', this.mumbleHost) // console.log('mumbleHost', this.mumbleHost)
console.log('mumblePort', this.mumblePort) // console.log('mumblePort', this.mumblePort)
console.log('murmurUser', this.murmurUser) // console.log('murmurUser', this.murmurUser)
console.log('murmurPassword', this.murmurPassword) // console.log('murmurPassword', this.murmurPassword)
this._createCertificatesForUser(id, () => { this._createCertificatesForUser(id, () => {
this._makeMumbleConnection(id, this.mumblePort, this.mumbleHost, id, this.murmurPassword, connectedCallback); this._makeMumbleConnection(id, this.mumblePort, this.mumbleHost, id, this.murmurPassword, connectedCallback);

View File

@ -36,19 +36,11 @@ class Simulator {
_start() { _start() {
const settings = this.configs.settings; const settings = this.configs.settings;
// this.assetIds.forEach((id, i) => {
this.assets.forEach((asset, i) => { this.assets.forEach((asset, i) => {
let delay_between_clients = 500; console.log('asset_id', asset.asset_id, i * settings.delay_between_clients + 'ms');
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);
setTimeout(() => { setTimeout(() => {
new Asset(asset, this.configs, this.token); new Asset(asset, this.configs, this.token);
// console.log('id, this.configs, this.token', id, this.configs, this.token) }, i * settings.delay_between_clients);
}, i * delay_between_clients);
}) })
} }