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
|
||||
.vscode
|
||||
logs/*
|
||||
!logs
|
||||
config/default.toml
|
||||
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
80
src/asset.js
80
src/asset.js
@ -344,8 +344,17 @@ class Asset {
|
||||
}
|
||||
|
||||
_start() {
|
||||
this.generate_voice && this._makePtt();
|
||||
this.generate_gps && this._sendGPS();
|
||||
this.generate_voice && this._makePtt(); // Generate voce
|
||||
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) {
|
||||
@ -458,19 +467,12 @@ class Asset {
|
||||
this.pttEndSuccessfully = true;
|
||||
setTimeout(() => {
|
||||
this._sendPttRelease();
|
||||
const now = +new Date();
|
||||
if(this.endTime > now) {
|
||||
if(this.endTime > +new Date()) {
|
||||
this._makePtt(callback);
|
||||
} else {
|
||||
|
||||
setTimeout(() => {
|
||||
utils.writeLog(`Asset: ${this.id} - STOP`)
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
}, 10000);
|
||||
utils.writeLog(`Asset ${this.id} Voice sleeping...`);
|
||||
}
|
||||
}, 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).
|
||||
@ -532,7 +534,7 @@ class Asset {
|
||||
})
|
||||
}
|
||||
|
||||
_sendGPS(callback) {
|
||||
_sendGPS() {
|
||||
let hub = this.hub;
|
||||
if (hub && hub.connected) {
|
||||
let lat = this.configs.settings.gps_lat_start_point;
|
||||
@ -547,36 +549,30 @@ class Asset {
|
||||
interval = this.configs.settings.gps_report_interval;
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
const now = +new Date();
|
||||
if(this.endTime > now) {
|
||||
var new_lat = this._randomCoordinates(lat);
|
||||
var new_lng = this._randomCoordinates(lng);
|
||||
const now = +new Date();
|
||||
if(this.endTime > now) {
|
||||
var new_lat = this._randomCoordinates(lat);
|
||||
var new_lng = this._randomCoordinates(lng);
|
||||
|
||||
hub.emit('gps', JSON.stringify(
|
||||
{
|
||||
unix_time: 1467126677000,
|
||||
asset_id: this.assetProps.id,
|
||||
asset_sip_id: this.assetProps.sip_id,
|
||||
speed_kmh: 16,
|
||||
lat: new_lat,
|
||||
lng: new_lng,
|
||||
accuracy: 20.3,
|
||||
activity_type: "driving",
|
||||
activity_confidence: 90
|
||||
}
|
||||
));
|
||||
lat = new_lat;
|
||||
lng = new_lng;
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
utils.writeLog(`Asset: ${this.id} - STOP`)
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
}, 11000);
|
||||
}
|
||||
}, interval);
|
||||
hub.emit('gps', JSON.stringify(
|
||||
{
|
||||
unix_time: 1467126677000,
|
||||
asset_id: this.assetProps.id,
|
||||
asset_sip_id: this.assetProps.sip_id,
|
||||
speed_kmh: 16,
|
||||
lat: new_lat,
|
||||
lng: new_lng,
|
||||
accuracy: 20.3,
|
||||
activity_type: "driving",
|
||||
activity_confidence: 90
|
||||
}
|
||||
));
|
||||
lat = new_lat;
|
||||
lng = new_lng;
|
||||
setTimeout(() => { this._sendGPS(); }, interval);
|
||||
} else {
|
||||
utils.writeLog(`Asset ${this.id} GPS sleeping...`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user