mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Fix forced lock removal and add frame mspStatistics
This commit is contained in:
parent
040b0cec52
commit
3e637c1c54
4 changed files with 55 additions and 5 deletions
|
@ -255,8 +255,10 @@ class Connection {
|
|||
getTimeout() {
|
||||
if (this._bitrate >= 57600) {
|
||||
return 3000;
|
||||
} else {
|
||||
} if (this._bitrate >= 19200) {
|
||||
return 4000;
|
||||
} else {
|
||||
return 6000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ const Safehome = require('./../safehome');
|
|||
const { FwApproach } = require('./../fwApproach');
|
||||
const Waypoint = require('./../waypoint');
|
||||
const mspDeduplicationQueue = require('./mspDeduplicationQueue');
|
||||
const mspStatistics = require('./mspStatistics');
|
||||
|
||||
var mspHelper = (function () {
|
||||
var self = {};
|
||||
|
@ -1619,7 +1620,12 @@ var mspHelper = (function () {
|
|||
*/
|
||||
if (dataHandler.callbacks[i]) {
|
||||
mspQueue.putRoundtrip(new Date().getTime() - dataHandler.callbacks[i].createdOn);
|
||||
mspQueue.putHardwareRoundtrip(new Date().getTime() - dataHandler.callbacks[i].sentOn);
|
||||
|
||||
const hardwareRountrip = new Date().getTime() - dataHandler.callbacks[i].sentOn;
|
||||
|
||||
mspQueue.putHardwareRoundtrip(hardwareRountrip);
|
||||
|
||||
mspStatistics.add(dataHandler.code, hardwareRountrip);
|
||||
}
|
||||
|
||||
//remove message from queue as received
|
||||
|
@ -3069,6 +3075,7 @@ var mspHelper = (function () {
|
|||
};
|
||||
|
||||
self._getSetting = function (name) {
|
||||
console.log("Getting setting " + name);
|
||||
if (FC.SETTINGS[name]) {
|
||||
return Promise.resolve(FC.SETTINGS[name]);
|
||||
}
|
||||
|
|
37
js/msp/mspStatistics.js
Normal file
37
js/msp/mspStatistics.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
var mspStatistics = function() {
|
||||
|
||||
let publicScope = {},
|
||||
privateScope = {};
|
||||
|
||||
privateScope.statistics = {};
|
||||
|
||||
|
||||
publicScope.add = function(code, duration) {
|
||||
if (!privateScope.statistics[code]) {
|
||||
privateScope.statistics[code] = {
|
||||
ctime: new Date().getTime(),
|
||||
count: 0,
|
||||
duration: 0,
|
||||
average: 0
|
||||
};
|
||||
}
|
||||
privateScope.statistics[code].count++;
|
||||
privateScope.statistics[code].duration += duration;
|
||||
privateScope.statistics[code].average = privateScope.statistics[code].duration / privateScope.statistics[code].count;
|
||||
};
|
||||
|
||||
publicScope.get = function() {
|
||||
return privateScope.statistics;
|
||||
};
|
||||
|
||||
publicScope.reset = function() {
|
||||
privateScope.statistics = {};
|
||||
};
|
||||
|
||||
return publicScope;
|
||||
|
||||
}();
|
||||
|
||||
module.exports = mspStatistics;
|
|
@ -294,16 +294,20 @@ var mspQueue = function () {
|
|||
var currentTimestamp = new Date().getTime(),
|
||||
threshold = publicScope.getHardwareRoundtrip() * 3;
|
||||
|
||||
if (threshold > 1000) {
|
||||
if (threshold > 5000) {
|
||||
threshold = 5000;
|
||||
}
|
||||
if (threshold < 1000) {
|
||||
threshold = 1000;
|
||||
}
|
||||
|
||||
if (privateScope.softLock !== false && currentTimestamp - privateScope.softLock > threshold) {
|
||||
privateScope.softLock = false;
|
||||
publicScope.freeSoftLock();
|
||||
eventFrequencyAnalyzer.put('force free soft lock');
|
||||
}
|
||||
if (privateScope.hardLock !== false && currentTimestamp - privateScope.hardLock > threshold) {
|
||||
privateScope.hardLock = false;
|
||||
console.log('Force free hard lock');
|
||||
publicScope.freeHardLock();
|
||||
eventFrequencyAnalyzer.put('force free hard lock');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue