2020-04-26 13:17:03 +00:00
|
|
|
var Modes = {
|
|
|
|
modes: [],
|
|
|
|
features: {},
|
2020-05-01 22:05:20 +00:00
|
|
|
panels: [],
|
2020-04-26 13:17:03 +00:00
|
|
|
setModes:function(json){
|
|
|
|
this.modes = json.map(function(m){ return new Mode(m); });
|
2020-05-01 22:05:20 +00:00
|
|
|
this.updatePanels();
|
|
|
|
},
|
|
|
|
getModes:function(){
|
|
|
|
return this.modes;
|
2020-04-26 13:17:03 +00:00
|
|
|
},
|
|
|
|
setFeatures:function(features){
|
|
|
|
this.features = features;
|
2020-05-01 22:05:20 +00:00
|
|
|
this.updatePanels();
|
2020-04-26 13:17:03 +00:00
|
|
|
},
|
|
|
|
findByModulation:function(modulation){
|
|
|
|
matches = this.modes.filter(function(m) { return m.modulation === modulation; });
|
|
|
|
if (matches.length) return matches[0]
|
2020-04-26 14:58:31 +00:00
|
|
|
},
|
2020-05-01 22:05:20 +00:00
|
|
|
registerModePanel: function(el) {
|
|
|
|
this.panels.push(el);
|
|
|
|
},
|
2020-05-02 13:07:47 +00:00
|
|
|
initComplete: function() {
|
|
|
|
return this.modes.length && Object.keys(this.features).length;
|
|
|
|
},
|
2020-05-01 22:05:20 +00:00
|
|
|
updatePanels: function() {
|
|
|
|
this.panels.forEach(function(p) {
|
|
|
|
p.render();
|
2020-05-02 13:07:47 +00:00
|
|
|
p.startDemodulator();
|
2020-04-26 15:18:48 +00:00
|
|
|
});
|
2020-04-26 13:17:03 +00:00
|
|
|
}
|
2020-04-26 15:18:48 +00:00
|
|
|
};
|
2020-04-26 13:17:03 +00:00
|
|
|
|
|
|
|
var Mode = function(json){
|
|
|
|
this.modulation = json.modulation;
|
|
|
|
this.name = json.name;
|
2020-04-26 16:45:41 +00:00
|
|
|
this.type = json.type;
|
2020-04-26 13:17:03 +00:00
|
|
|
this.requirements = json.requirements;
|
2020-05-03 17:55:48 +00:00
|
|
|
this.squelch = json.squelch;
|
2020-04-26 16:45:41 +00:00
|
|
|
if (json.bandpass) {
|
|
|
|
this.bandpass = json.bandpass;
|
|
|
|
}
|
|
|
|
if (this.type === 'digimode') {
|
|
|
|
this.underlying = json.underlying;
|
|
|
|
}
|
2020-04-26 13:17:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Mode.prototype.isAvailable = function(){
|
|
|
|
return this.requirements.map(function(r){
|
|
|
|
return Modes.features[r];
|
|
|
|
}).reduce(function(a, b){
|
|
|
|
return a && b;
|
|
|
|
}, true);
|
2020-05-01 22:05:20 +00:00
|
|
|
};
|