1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 11:29:53 +03:00
inav-configurator/js/motorMixerRuleCollection.js
Pawel Spychalski (DzikuVx) eb208af39d chainer for motors tab
2018-02-01 15:45:23 +01:00

59 lines
No EOL
1.1 KiB
JavaScript

/*global $, MotorMixRule*/
'use strict';
var MotorMixerRuleCollection = function () {
var self = {};
var data = [];
self.motorCount = 0;
self.setMotorCount = function (value) {
self.motorCount = value;
};
self.getMotorCount = function () {
return self.motorCount;
};
self.put = function (element) {
data.push(element);
};
self.get = function () {
return data;
};
self.drop = function (index) {
data[index].setThrottle(0);
self.cleanup();
};
self.flush = function () {
data = [];
};
self.cleanup = function () {
var tmpData = [];
data.forEach(function (element) {
if (element.isUsed()) {
tmpData.push(element);
}
});
data = tmpData;
};
self.inflate = function () {
while (self.hasFreeSlots()) {
self.put(new MotorMixRule(0, 0, 0, 0));
}
};
self.hasFreeSlots = function () {
return data.length < self.getMotorCount();
};
return self;
};