2019-10-14 16:48:35 +00:00
|
|
|
# See: http://wiki.flightgear.org/MapStructure
|
|
|
|
# Class things:
|
|
|
|
var name ='VOR-airbus';
|
|
|
|
var parents = [SymbolLayer.Controller];
|
|
|
|
var __self__ = caller(0)[0];
|
|
|
|
SymbolLayer.Controller.add(name, __self__);
|
|
|
|
SymbolLayer.add(name, {
|
2019-12-29 21:37:52 +00:00
|
|
|
parents: [NavaidSymbolLayer],
|
|
|
|
type: name, # Symbol type
|
|
|
|
df_controller: __self__, # controller to use by default -- this one
|
|
|
|
df_options: {
|
|
|
|
vor1_frq: 'instrumentation/nav[2]/frequencies/selected-mhz',
|
|
|
|
vor2_frq: 'instrumentation/nav[3]/frequencies/selected-mhz'
|
|
|
|
},
|
|
|
|
df_style: {
|
|
|
|
scale: 1
|
|
|
|
}
|
2019-10-14 16:48:35 +00:00
|
|
|
});
|
|
|
|
var new = func(layer) {
|
2019-12-29 21:37:52 +00:00
|
|
|
var m = {
|
|
|
|
parents: [__self__],
|
|
|
|
layer: layer,
|
|
|
|
map: layer.map,
|
|
|
|
active_vors: [],
|
|
|
|
navNs: props.globals.getNode("instrumentation").getChildren("nav"),
|
|
|
|
listeners: [],
|
|
|
|
query_type:'vor',
|
|
|
|
};
|
|
|
|
setsize(m.active_vors, size(m.navNs));
|
|
|
|
foreach (var navN; m.navNs) {
|
|
|
|
append(m.listeners, setlistener(
|
|
|
|
navN.getNode("frequencies/selected-mhz"),
|
|
|
|
func m.changed_freq()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
#call(debug.dump, keys(layer));
|
|
|
|
m.changed_freq(update:0);
|
|
|
|
m.addVisibilityListener();
|
2019-10-14 16:48:35 +00:00
|
|
|
|
2019-12-29 21:37:52 +00:00
|
|
|
return m;
|
2019-10-14 16:48:35 +00:00
|
|
|
};
|
|
|
|
var del = func() {
|
2020-04-22 14:40:25 +00:00
|
|
|
logprint(_MP_dbg_lvl, name,".lcontroller.del()");
|
2019-12-29 21:37:52 +00:00
|
|
|
foreach (var l; me.listeners)
|
|
|
|
removelistener(l);
|
2019-10-14 16:48:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Controller methods
|
|
|
|
var isActive = func(model) {
|
2019-12-29 21:37:52 +00:00
|
|
|
var my_freq = model.frequency/100;
|
|
|
|
foreach (var freq; me.active_vors)
|
|
|
|
if (freq == my_freq) return 1;
|
|
|
|
return 0;
|
2019-10-14 16:48:35 +00:00
|
|
|
};
|
|
|
|
var changed_freq = func(update=1) {
|
2019-12-29 21:37:52 +00:00
|
|
|
#debug.dump(me.active_vors);
|
|
|
|
foreach (var navN; me.navNs)
|
|
|
|
me.active_vors[ navN.getIndex() ] = navN.getValue("frequencies/selected-mhz");
|
|
|
|
if (update) me.layer.update();
|
2019-10-14 16:48:35 +00:00
|
|
|
};
|
|
|
|
|
2020-04-22 14:40:25 +00:00
|
|
|
var searchCmd = NavaidSymbolLayer.make('vor');
|