mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 21:05:28 +03:00
Deduplicatrion of the queue and delayed release of hard lock
This commit is contained in:
parent
a4fd2bce9d
commit
93bb0eba4f
3 changed files with 32 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
const MSPCodes = require('./msp/MSPCodes')
|
const MSPCodes = require('./msp/MSPCodes')
|
||||||
const mspQueue = require('./serial_queue');
|
const mspQueue = require('./serial_queue');
|
||||||
|
const eventFrequencyAnalyzer = require('./eventFrequencyAnalyzer');
|
||||||
|
const timeout = require('./timeouts');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -265,7 +267,9 @@ var MSP = {
|
||||||
/*
|
/*
|
||||||
* Free port
|
* Free port
|
||||||
*/
|
*/
|
||||||
|
timeout.add('delayedFreeHardLock', function() {
|
||||||
mspQueue.freeHardLock();
|
mspQueue.freeHardLock();
|
||||||
|
}, 50);
|
||||||
|
|
||||||
// Reset variables
|
// Reset variables
|
||||||
this.message_length_received = 0;
|
this.message_length_received = 0;
|
||||||
|
@ -301,6 +305,8 @@ var MSP = {
|
||||||
var checksum;
|
var checksum;
|
||||||
var ii;
|
var ii;
|
||||||
|
|
||||||
|
eventFrequencyAnalyzer.put('MPS ' + code);
|
||||||
|
|
||||||
if (!protocolVersion) {
|
if (!protocolVersion) {
|
||||||
protocolVersion = this.protocolVersion;
|
protocolVersion = this.protocolVersion;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ var SerialBackend = (function () {
|
||||||
|
|
||||||
privateScope.isDemoRunning = false;
|
privateScope.isDemoRunning = false;
|
||||||
|
|
||||||
|
privateScope.isWirelessMode = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle "Wireless" mode with strict queueing of messages
|
* Handle "Wireless" mode with strict queueing of messages
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,6 +59,15 @@ var mspQueue = function () {
|
||||||
|
|
||||||
privateScope.queueLocked = false;
|
privateScope.queueLocked = false;
|
||||||
|
|
||||||
|
privateScope.isMessageInQueue = function (code) {
|
||||||
|
for (var i = 0; i < privateScope.queue.length; i++) {
|
||||||
|
if (privateScope.queue[i].code == code) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
publicScope.setremoveCallback = function(cb) {
|
publicScope.setremoveCallback = function(cb) {
|
||||||
privateScope.removeCallback = cb;
|
privateScope.removeCallback = cb;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +95,10 @@ var mspQueue = function () {
|
||||||
privateScope.lockMethod = method;
|
privateScope.lockMethod = method;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
publicScope.getLockMethod = function () {
|
||||||
|
return privateScope.lockMethod;
|
||||||
|
};
|
||||||
|
|
||||||
publicScope.setSoftLock = function () {
|
publicScope.setSoftLock = function () {
|
||||||
privateScope.softLock = new Date().getTime();
|
privateScope.softLock = new Date().getTime();
|
||||||
};
|
};
|
||||||
|
@ -223,6 +236,12 @@ var mspQueue = function () {
|
||||||
*/
|
*/
|
||||||
publicScope.put = function (mspRequest) {
|
publicScope.put = function (mspRequest) {
|
||||||
|
|
||||||
|
console.log(mspRequest.code);
|
||||||
|
if (privateScope.isMessageInQueue(mspRequest.code)) {
|
||||||
|
console.log('Message already in queue: ' + mspRequest.code);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (privateScope.queueLocked === true) {
|
if (privateScope.queueLocked === true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -317,6 +336,10 @@ var mspQueue = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
publicScope.getQueue = function () {
|
||||||
|
return privateScope.queue;
|
||||||
|
};
|
||||||
|
|
||||||
setInterval(publicScope.executor, Math.round(1000 / privateScope.handlerFrequency));
|
setInterval(publicScope.executor, Math.round(1000 / privateScope.handlerFrequency));
|
||||||
setInterval(publicScope.balancer, Math.round(1000 / privateScope.balancerFrequency));
|
setInterval(publicScope.balancer, Math.round(1000 / privateScope.balancerFrequency));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue