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);
|
|
|
|
},
|
|
|
|
updatePanels: function() {
|
2020-05-01 23:07:44 +00:00
|
|
|
var init_complete = this.modes.length && Object.keys(this.features).length;
|
2020-05-01 22:05:20 +00:00
|
|
|
this.panels.forEach(function(p) {
|
|
|
|
p.render();
|
|
|
|
if (init_complete) {
|
|
|
|
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-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
|
|
|
};
|