... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
var buttonsClass = { |
2 |
- new : func (node) { |
|
2 |
+ new : func (device) { |
|
3 | 3 |
var m = { parents: [ buttonsClass ] }; |
4 |
- m.node = node; |
|
4 |
+ m.device = device; |
|
5 | 5 |
return m; |
6 | 6 |
}, |
7 | 7 |
|
... | ... |
@@ -69,19 +69,20 @@ var setListeners = func { |
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
var deviceClass = { |
72 |
- new: func (role) { |
|
72 |
+ new: func (name) { |
|
73 | 73 |
var m = { parents: [ deviceClass ] }; |
74 |
- m.role = role; |
|
75 |
- m.node = zkv.getNode(role, 1); |
|
74 |
+ m.name = name; |
|
75 |
+ m.role = substr(name, 0, 3); |
|
76 |
+ m.node = zkv.getNode(name, 1); |
|
76 | 77 |
m.data = {}; |
77 | 78 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) { |
78 | 79 |
m.data[v] = alerts.getNode(v).getValue(); |
79 | 80 |
m.data[v ~ '-visible'] = 1; |
80 | 81 |
} |
81 |
- m.display = displayClass.new(m, m.role); |
|
82 |
- m.display.showInitProgress(m.role); |
|
83 |
- m.softkeys = softkeysClass.new(m, m.node, m.role); |
|
84 |
- m.buttons = buttonsClass.new(m.node); |
|
82 |
+ m.display = displayClass.new(m); |
|
83 |
+ m.display.showInitProgress(m.name); |
|
84 |
+ m.softkeys = softkeysClass.new(m); |
|
85 |
+ m.buttons = buttonsClass.new(m); |
|
85 | 86 |
m.knobs = knobsClass.new(m); |
86 | 87 |
m.display.loadsvg(); |
87 | 88 |
m.display.loadGroup({ |
... | ... |
@@ -99,18 +100,18 @@ var deviceClass = { |
99 | 100 |
clip : 'PitchScale', |
100 | 101 |
}); |
101 | 102 |
m.windows = pageClass.new(m); |
102 |
- zkv.getNode(m.role ~ 'init').setIntValue(0); |
|
103 |
- setprop('/instrumentation/zkv1000/' ~ m.role ~ '/status', 1); |
|
104 |
- msg(m.role ~ ' switched on!'); |
|
103 |
+ zkv.getNode(m.name ~ '-init').setIntValue(0); |
|
104 |
+ setprop('/instrumentation/zkv1000/' ~ m.name ~ '/status', 1); |
|
105 |
+ msg(m.name ~ ' switched on!'); |
|
105 | 106 |
return m; |
106 | 107 |
}, |
107 | 108 |
}; |
108 | 109 |
|
109 | 110 |
var powerOn = func { |
110 |
- foreach (var role; keys(flightdeck)) |
|
111 |
- if (zkv.getNode(role) != nil) |
|
111 |
+ foreach (var name; keys(flightdeck)) |
|
112 |
+ if (zkv.getNode(name) != nil) |
|
112 | 113 |
# thread.newthread(func { |
113 |
- flightdeck[role] = deviceClass.new(role); |
|
114 |
+ flightdeck[name] = deviceClass.new(name); |
|
114 | 115 |
# }); |
115 | 116 |
settimer(setListeners, 5); |
116 | 117 |
} |
... | ... |
@@ -1,21 +1,21 @@ |
1 | 1 |
# vim: set foldmethod=marker foldmarker={{{,}}} : |
2 | 2 |
var displayClass = { |
3 |
- new: func(device, role) { |
|
3 |
+ new: func(device) { |
|
4 | 4 |
# the contructor {{{ |
5 | 5 |
var m = { parents: [ displayClass ] }; |
6 | 6 |
|
7 | 7 |
m.display = canvas.new({ |
8 |
- "name" : role, |
|
8 |
+ "name" : device.name, |
|
9 | 9 |
"size" : [1024, 768], |
10 | 10 |
"view" : [1024, 768], |
11 | 11 |
"mipmapping": 1 |
12 | 12 |
}); |
13 | 13 |
m.display.addPlacement({ |
14 | 14 |
"node": "Screen", |
15 |
- "parent": role |
|
15 |
+ "parent": device.name |
|
16 | 16 |
}); |
17 | 17 |
m.display.setColorBackground(0,0,0); |
18 |
- m.role = substr(role, 0, 3); |
|
18 |
+ m.role = device.role; |
|
19 | 19 |
m.device = device; |
20 | 20 |
m.screenElements = {}; |
21 | 21 |
|
... | ... |
@@ -23,7 +23,7 @@ var displayClass = { |
23 | 23 |
# Softkeys revert to the previous level after 45 seconds of inactivity. |
24 | 24 |
m.softkeys_inactivity_delay = 45; |
25 | 25 |
|
26 |
- if (role == 'MFD') { |
|
26 |
+ if (device.role == 'MFD') { |
|
27 | 27 |
m.MFDMapTiles = MapTiles.new(m.display); |
28 | 28 |
m.MFDMapNavDisplay = MapNavDisplay.new(m.display); |
29 | 29 |
var eis_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/EIS/'; |
... | ... |
@@ -73,7 +73,7 @@ var displayClass = { |
73 | 73 |
_showInitProgress : func (p,t) { |
74 | 74 |
#{{{ |
75 | 75 |
p.setText(t); |
76 |
- if (zkv.getNode(me.device.role ~ 'init').getValue() != 0) { |
|
76 |
+ if (zkv.getNode(me.device.name ~ '-init').getValue() != 0) { |
|
77 | 77 |
if (size(t) >= 10) t = ''; |
78 | 78 |
settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1); |
79 | 79 |
} |
... | ... |
@@ -104,7 +104,7 @@ var displayClass = { |
104 | 104 |
append(groups.show, sprintf("SoftKey%02i-bg", k)); |
105 | 105 |
} |
106 | 106 |
|
107 |
- if (me.role == 'PFD') { |
|
107 |
+ if (me.device.role == 'PFD') { |
|
108 | 108 |
append(groups.show, |
109 | 109 |
'XPDR-TIME', |
110 | 110 |
'FlightInstruments', |
... | ... |
@@ -198,7 +198,7 @@ var displayClass = { |
198 | 198 |
foreach (var freq; keys(data.timers)) |
199 | 199 |
data.timers[freq].start(); |
200 | 200 |
|
201 |
- if (me.role == 'PFD') { |
|
201 |
+ if (me.device.role == 'PFD') { |
|
202 | 202 |
me.updateAI(); |
203 | 203 |
me.updateVSI(); |
204 | 204 |
me.updateIAS(); |
... | ... |
@@ -227,26 +227,26 @@ var displayClass = { |
227 | 227 |
me.progress = nil; |
228 | 228 |
me.showInitProgress = nil; |
229 | 229 |
me._showInitProgress = nil; |
230 |
- zkv.removeChild(me.role ~ 'init'); |
|
230 |
+ zkv.removeChild(me.device.role ~ 'init', 0); |
|
231 | 231 |
} |
232 | 232 |
}, |
233 | 233 |
#}}} |
234 | 234 |
|
235 |
- showInitProgress : func (role) { |
|
235 |
+ showInitProgress : func (name) { |
|
236 | 236 |
#{{{ |
237 | 237 |
me.progress = me.display.createGroup(); |
238 | 238 |
me.progress.show(); |
239 |
- me.progress.createChild("text", role ~ " title") |
|
239 |
+ me.progress.createChild("text", name ~ " title") |
|
240 | 240 |
.setTranslation(512, 384) |
241 | 241 |
.setAlignment("center-center") |
242 | 242 |
.setFont("LiberationFonts/LiberationSans-Italic.ttf") |
243 | 243 |
.setFontSize(64, 1) |
244 | 244 |
.setColor(1,1,1) |
245 |
- .setText("ZKV1000 " ~ role ~ " init"); |
|
245 |
+ .setText("ZKV1000 " ~ name ~ " init"); |
|
246 | 246 |
|
247 |
- zkv.getNode(role ~ 'init',1).setIntValue(1); |
|
247 |
+ zkv.getNode(name ~ '-init',1).setIntValue(1); |
|
248 | 248 |
|
249 |
- me._showInitProgress(me.progress.createChild("text", role ~ "progress") |
|
249 |
+ me._showInitProgress(me.progress.createChild("text", name ~ "progress") |
|
250 | 250 |
.setTranslation(512, 484) |
251 | 251 |
.setAlignment("center-center") |
252 | 252 |
.setFont("LiberationFonts/LiberationSans-Bold.ttf") |
... | ... |
@@ -413,7 +413,7 @@ var displayClass = { |
413 | 413 |
updateSoftKeys : func { |
414 | 414 |
# update SoftKeys boxes {{{ |
415 | 415 |
# on PFD the last boxes are always BACK and ALERTS |
416 |
- if (me.role == 'PFD') { |
|
416 |
+ if (me.device.role == 'PFD') { |
|
417 | 417 |
me.screenElements[sprintf("SoftKey%02i-text", 11)] |
418 | 418 |
.setText('ALERTS'); |
419 | 419 |
if (size(me.device.softkeys.path) != 0) |
... | ... |
@@ -421,7 +421,7 @@ var displayClass = { |
421 | 421 |
.setText('BACK'); |
422 | 422 |
} |
423 | 423 |
|
424 |
- var path = keyMap[me.role]; |
|
424 |
+ var path = keyMap[me.device.role]; |
|
425 | 425 |
foreach (var p; me.device.softkeys.path) |
426 | 426 |
path = path[p]; |
427 | 427 |
|
... | ... |
@@ -438,7 +438,7 @@ var displayClass = { |
438 | 438 |
.setText(path.texts[k]); |
439 | 439 |
} |
440 | 440 |
# feeding the last boxes with empty string |
441 |
- var end = (me.role == 'PFD') ? 10 : 12; |
|
441 |
+ var end = (me.device.role == 'PFD') ? 10 : 12; |
|
442 | 442 |
if (size(path.texts) + start < end) { |
443 | 443 |
start = size(path.texts) + start; |
444 | 444 |
for (var k = start; k < end; k += 1) |
... | ... |
@@ -729,7 +729,7 @@ var displayClass = { |
729 | 729 |
|
730 | 730 |
updateHDG : func () { |
731 | 731 |
# moves the heading bug and display heading-deg for 3 seconds (PFD) {{{ |
732 |
- if (me.role == 'MFD') |
|
732 |
+ if (me.device.role == 'MFD') |
|
733 | 733 |
return; |
734 | 734 |
var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg'); |
735 | 735 |
me.screenElements['Heading-bug'] |
... | ... |
@@ -747,7 +747,7 @@ var displayClass = { |
747 | 747 |
|
748 | 748 |
updateCRS : func () { |
749 | 749 |
# TODO: update display for NAV/GPS/BRG courses {{{ |
750 |
- if (me.role == 'MFD') |
|
750 |
+ if (me.device.role == 'MFD') |
|
751 | 751 |
return; |
752 | 752 |
var source = getprop('/instrumentation/zkv1000/cdi/source'); |
753 | 753 |
if (source == 'OFF') |
... | ... |
@@ -1,9 +1,7 @@ |
1 | 1 |
var softkeysClass = { |
2 |
- new : func (device, node, role) { |
|
2 |
+ new : func (device) { |
|
3 | 3 |
var m = { parents: [ softkeysClass ] }; |
4 |
- m.node = node; |
|
5 | 4 |
m.device = device; |
6 |
- m.role = substr(role, 0, 3); |
|
7 | 5 |
m.path = []; |
8 | 6 |
return m; |
9 | 7 |
}, |
... | ... |
@@ -17,7 +15,7 @@ var softkeysClass = { |
17 | 15 |
if (key == '' or key == nil) |
18 | 16 |
return; |
19 | 17 |
|
20 |
- var path = keyMap[me.role]; |
|
18 |
+ var path = keyMap[me.device.role]; |
|
21 | 19 |
foreach(var p; me.path) { |
22 | 20 |
if (contains(path, p)) |
23 | 21 |
path = path[p]; |
... | ... |
@@ -25,7 +23,7 @@ var softkeysClass = { |
25 | 23 |
break; |
26 | 24 |
} |
27 | 25 |
|
28 |
- var bindings = me.bindings[me.role]; |
|
26 |
+ var bindings = me.bindings[me.device.role]; |
|
29 | 27 |
foreach(var p; me.path) { |
30 | 28 |
if (contains(bindings, p)) |
31 | 29 |
bindings = bindings[p]; |