LAPI:705: Generate GPS and voice are two separate process; Added exit function
This commit is contained in:
parent
0c62a937ec
commit
2a22d7a209
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
.vscode
|
.vscode
|
||||||
logs/*
|
|
||||||
!logs
|
|
||||||
config/default.toml
|
config/default.toml
|
||||||
certs
|
certs
|
28
config/dev/default.sergiu.toml
Normal file
28
config/dev/default.sergiu.toml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[elogs]
|
||||||
|
name = 'dev'
|
||||||
|
|
||||||
|
[api]
|
||||||
|
port = ''
|
||||||
|
host = 'node.dev.linx.safemobile.com/api'
|
||||||
|
use_secure = true
|
||||||
|
accept_untrusted_certs = true
|
||||||
|
|
||||||
|
[settings]
|
||||||
|
max_fails = 3
|
||||||
|
send_group_monitoring_before_each_call = 'false'
|
||||||
|
gps_report_interval = ''
|
||||||
|
gps_min_interval = 500
|
||||||
|
gps_max_interval = 1000
|
||||||
|
gps_lat_start_point = 46.217802
|
||||||
|
gps_lng_start_point = 24.776126
|
||||||
|
delay_between_clients = 500
|
||||||
|
testing_duration = 10 # seconds
|
||||||
|
|
||||||
|
[[assets]]
|
||||||
|
asset_id = 60
|
||||||
|
group_id = 1
|
||||||
|
generate_voice = true
|
||||||
|
generate_gps = true
|
||||||
|
|
||||||
|
[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']
|
0
logs/error_dev.log
Normal file
0
logs/error_dev.log
Normal file
0
logs/simulator_dev.log
Normal file
0
logs/simulator_dev.log
Normal file
38
src/asset.js
38
src/asset.js
@ -344,8 +344,17 @@ class Asset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_start() {
|
_start() {
|
||||||
this.generate_voice && this._makePtt();
|
this.generate_voice && this._makePtt(); // Generate voce
|
||||||
this.generate_gps && this._sendGPS();
|
this.generate_gps && this._sendGPS(); // Generate GPS
|
||||||
|
this._measuringTestTime(); // Process exit base on this.endTime and current date
|
||||||
|
}
|
||||||
|
|
||||||
|
_measuringTestTime() {
|
||||||
|
setInterval(() => {
|
||||||
|
if(Date.now() > this.endTime + 18000) {
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
_verifyRecorder(callback) {
|
_verifyRecorder(callback) {
|
||||||
@ -458,19 +467,12 @@ class Asset {
|
|||||||
this.pttEndSuccessfully = true;
|
this.pttEndSuccessfully = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this._sendPttRelease();
|
this._sendPttRelease();
|
||||||
const now = +new Date();
|
if(this.endTime > +new Date()) {
|
||||||
if(this.endTime > now) {
|
|
||||||
this._makePtt(callback);
|
this._makePtt(callback);
|
||||||
} else {
|
} else {
|
||||||
|
utils.writeLog(`Asset ${this.id} Voice sleeping...`);
|
||||||
setTimeout(() => {
|
|
||||||
utils.writeLog(`Asset: ${this.id} - STOP`)
|
|
||||||
.then(() => {
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
}, 10000);
|
|
||||||
}
|
}
|
||||||
}, 1800); // Hangtime
|
}, 1500); // Hangtime
|
||||||
});
|
});
|
||||||
|
|
||||||
// @TODO: Ugly hack for the voice to work with mp3 (The fix is to remove float32ToInt16 conversion). It is the _transform function from OpusEncoderStream class (mumble-client-codecs-node project).
|
// @TODO: Ugly hack for the voice to work with mp3 (The fix is to remove float32ToInt16 conversion). It is the _transform function from OpusEncoderStream class (mumble-client-codecs-node project).
|
||||||
@ -532,7 +534,7 @@ class Asset {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendGPS(callback) {
|
_sendGPS() {
|
||||||
let hub = this.hub;
|
let hub = this.hub;
|
||||||
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;
|
||||||
@ -547,7 +549,6 @@ class Asset {
|
|||||||
interval = this.configs.settings.gps_report_interval;
|
interval = this.configs.settings.gps_report_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
const now = +new Date();
|
const now = +new Date();
|
||||||
if(this.endTime > now) {
|
if(this.endTime > now) {
|
||||||
var new_lat = this._randomCoordinates(lat);
|
var new_lat = this._randomCoordinates(lat);
|
||||||
@ -568,15 +569,10 @@ class Asset {
|
|||||||
));
|
));
|
||||||
lat = new_lat;
|
lat = new_lat;
|
||||||
lng = new_lng;
|
lng = new_lng;
|
||||||
|
setTimeout(() => { this._sendGPS(); }, interval);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
utils.writeLog(`Asset ${this.id} GPS sleeping...`);
|
||||||
utils.writeLog(`Asset: ${this.id} - STOP`)
|
|
||||||
.then(() => {
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
}, 11000);
|
|
||||||
}
|
}
|
||||||
}, interval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user