commit initial
|
1 |
var displayClass = { |
2 |
new: func(node, role) { |
|
3 |
var m = { parents: [ displayClass ] }; |
|
4 |
|
|
5 |
m.display = canvas.new({ |
|
6 |
"name" : role, |
|
7 |
"size" : [1024, 768], |
|
8 |
"view" : [1024, 768], |
|
9 |
"mipmapping": 1 |
|
10 |
}); |
|
11 |
m.display.addPlacement({ |
|
12 |
"node": "Screen", |
|
13 |
"parent": role |
|
14 |
}); |
|
15 |
m.display.setColorBackground(0,0,0); |
|
16 |
m.role = role; |
|
écriture du wrapper pour le ...
|
17 |
m.screenElements = {}; |
commit initial
|
18 | |
19 |
return m; |
|
20 |
}, |
|
21 | ||
22 |
loadsvg : func () { |
|
23 |
me.screen = me.display.createGroup(); |
|
24 |
me.screen.hide(); |
|
25 |
canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg"); |
|
26 |
}, |
|
27 | ||
28 |
_showInitProgress : func (p,t) { |
|
29 |
p.setText(t); |
|
30 |
if (zkv.getNode(me.role ~ 'init').getValue() != 0) { |
|
31 |
if (size(t) >= 10) t = ''; |
|
32 |
settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1); |
|
33 |
} |
|
34 |
else { |
|
35 |
me.progress.hide(); |
|
36 |
me.screen.show(); |
|
animation VSI
|
37 |
me.loadGroup({ |
38 |
show : [ |
|
commit initial
|
39 |
'SoftKeysTexts', |
40 |
'COMM', |
|
41 |
'NAV', |
|
42 |
'XPDR-TIME', |
|
AI disponible
|
43 |
'FlightInstruments', |
44 |
'Horizon', |
|
AI disponible, avec bankPoin...
|
45 |
'bankPointer', |
animation VSI
|
46 |
'VSI', |
animation HSI
|
47 |
'Rose', |
48 |
], |
|
49 |
hide : [ |
|
50 |
'HDI', |
|
51 |
'NAV1-pointer', |
|
52 |
'NAV2-pointer', |
|
53 |
'GPS-pointer', |
|
54 |
'Bearing1', |
|
55 |
'Bearing2', |
|
animation VSI
|
56 |
], |
animation IAS
|
57 |
text: [ |
58 |
'VSIText', |
|
animation ALT
|
59 |
'Speed110', |
animation HSI
|
60 |
'Alt11100', |
61 |
'HDG-text', |
|
animation IAS
|
62 |
], |
63 |
clip: [ |
|
64 |
'SpeedLint1', |
|
animation ALT
|
65 |
'SpeedTape', |
66 |
'LintAlt', |
|
67 |
'AltLint00011' |
|
animation IAS
|
68 |
], |
animation VSI
|
69 |
}); |
animation IAS
|
70 | |
animation ALT
|
71 |
var AltBigAltSmall = [ 'AltBigC', 'AltSmallC' ]; |
72 |
for (var place = 1; place <= 6; place +=1) { |
|
73 |
append(AltBigAltSmall, |
|
74 |
'AltBigU' ~ place, |
|
75 |
'AltSmallU' ~ place, |
|
76 |
'AltBigD' ~ place, |
|
77 |
'AltSmallD' ~ place |
|
78 |
); |
|
79 |
} |
|
80 |
me.loadGroup({text: AltBigAltSmall}); |
|
81 | ||
AI disponible, avec bankPoin...
|
82 |
me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')); |
animation VSI
|
83 |
me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')); |
animation IAS
|
84 |
me.updateIAS(getprop('/velocities/airspeed-kt')); |
animation ALT
|
85 |
me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')); |
animation HSI
|
86 |
me.updateHSI(getprop('orientation/heading-deg')); |
commit initial
|
87 |
me.progress.removeAllChildren(); |
88 |
me.progress = nil; |
|
89 |
me.showInitProgress = nil; |
|
90 |
me._showInitProgress = nil; |
|
91 |
zkv.removeChild(me.role ~ 'init'); |
|
92 |
} |
|
93 |
}, |
|
94 | ||
95 |
showInitProgress : func (role) { |
|
96 |
me.progress = me.display.createGroup(); |
|
97 |
me.progress.show(); |
|
98 |
me.progress.createChild("text", role ~ " title") |
|
99 |
.setTranslation(512, 384) |
|
100 |
.setAlignment("center-center") |
|
101 |
.setFont("LiberationFonts/LiberationSans-Italic.ttf") |
|
102 |
.setFontSize(64, 1) |
|
103 |
.setColor(1,1,1) |
|
104 |
.setText("ZKV1000 " ~ role ~ " init"); |
|
105 | ||
106 |
zkv.getNode(role ~ 'init',1).setIntValue(1); |
|
107 | ||
108 |
me._showInitProgress(me.progress.createChild("text", role ~ "progress") |
|
109 |
.setTranslation(512, 484) |
|
110 |
.setAlignment("center-center") |
|
111 |
.setFont("LiberationFonts/LiberationSans-Bold.ttf") |
|
112 |
.setFontSize(128, 1) |
|
113 |
.setColor(1,0,0), '.'); |
|
114 |
}, |
|
115 | ||
écriture du wrapper pour le ...
|
116 |
loadGroup : func (h) { |
117 |
if (typeof(h) != 'hash') { |
|
118 |
msg_dbg(sprintf("%s need a hash, but get a %s from %s", |
|
119 |
caller(0)[0], |
|
120 |
typeof(h), |
|
121 |
caller(1)[0])); |
|
122 |
return; |
|
commit initial
|
123 |
} |
écriture du wrapper pour le ...
|
124 |
var setMethod = func (e, t) { |
125 |
if (t == 'hide') |
|
126 |
me.screenElements[e].hide(); |
|
127 |
elsif (t == 'show') |
|
128 |
me.screenElements[e].show(); |
|
AI disponible
|
129 |
elsif (t == 'rot' or t == 'trans') { |
130 |
if (! contains(me.screenElements[e], t)) |
|
131 |
me.screenElements[e][t] = me.screenElements[e].createTransform(); |
|
132 |
} |
|
133 |
elsif (t == 'clip') { |
|
134 |
if (contains(me.clips, e)) |
|
135 |
me.screenElements[e].set("clip", me.clips[e]); |
|
136 |
else |
|
137 |
print('no defined clip for ' ~ e); |
|
138 |
} |
|
animation VSI
|
139 |
elsif (t == 'text') { |
140 |
if (contains(me.texts, e)) { |
|
141 |
if (contains(me.texts[e], 'alignment')) |
|
142 |
me.screenElements[e].setAlignment(me.texts[e].alignment); |
|
143 |
if (contains(me.texts[e], 'default')) |
|
144 |
me.screenElements[e].setText(me.texts[e].default); |
|
145 |
} |
|
146 |
else |
|
147 |
print('no alignment for ' ~ e); |
|
148 |
} |
|
commit initial
|
149 |
else |
écriture du wrapper pour le ...
|
150 |
print('unknown method ' ~ t); |
151 |
}; |
|
152 |
foreach (var todo; keys(h)) { |
|
153 |
if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ]; |
|
154 |
foreach (var id; h[todo]) { |
|
155 |
if (! contains(me.screenElements, id)) { |
|
156 |
me.screenElements[id] = me.screen.getElementById(id); |
|
157 |
if (me.screenElements[id] != nil) |
|
158 |
setMethod(id, todo); |
|
159 |
else |
|
160 |
print('SVG ID ' ~ id ~ ' not found'); |
|
161 |
} |
|
162 |
else |
|
163 |
setMethod(id, todo); |
|
164 |
} |
|
commit initial
|
165 |
} |
166 |
}, |
|
AI disponible
|
167 | |
168 |
clips : { |
|
169 |
PitchScale : "rect(70,664,370,256)", |
|
animation IAS
|
170 |
SpeedLint1 : "rect(252,226,318,204)", |
171 |
SpeedTape : "rect(115,239,455,156)", |
|
animation ALT
|
172 |
LintAlt : "rect(115,808,455,704)", |
173 |
AltLint00011 : "rect(252,804,318,771)", |
|
AI disponible
|
174 |
}, |
175 | ||
animation VSI
|
176 |
texts : { |
177 |
VSIText : { |
|
178 |
alignment: "right-bottom", default : num('0'), |
|
179 |
}, |
|
animation IAS
|
180 |
Speed110 : { |
181 |
default: '', alignment : 'left-bottom' |
|
182 |
}, |
|
animation ALT (2)
|
183 |
Alt11100 : { |
184 |
default:'', alignment:'left-bottom' |
|
185 |
}, |
|
animation VSI
|
186 |
}, |
187 | ||
AI disponible, avec bankPoin...
|
188 |
updateAI: func(roll,pitch){ |
AI disponible
|
189 |
if (pitch > 80) |
190 |
pitch = 80; |
|
191 |
elsif(pitch < -80) |
|
192 |
pitch = -80; |
|
193 |
me.screenElements.Horizon |
|
194 |
.setRotation(-roll * D2R) |
|
195 |
.setTranslation(0, pitch * 6.8571428); |
|
AI disponible, avec bankPoin...
|
196 |
me.screenElements.bankPointer |
197 |
.setRotation(-roll * D2R); |
|
198 |
settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1); |
|
AI disponible
|
199 |
}, |
animation VSI
|
200 | |
201 |
updateVSI: func (vsi) { |
|
202 |
me.screenElements.VSIText |
|
203 |
.setText(num(math.round(vsi, 10))); |
|
204 |
if (vsi > 4500) |
|
205 |
vsi = 4500; |
|
206 |
elsif (vsi < -4500) |
|
207 |
vsi = -4500; |
|
208 |
me.screenElements.VSI |
|
209 |
.setTranslation(0, vsi * -0.03465); |
|
210 |
settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1); |
|
211 |
}, |
|
animation IAS
|
212 | |
213 |
updateIAS: func (ias) { |
|
214 |
if (ias >= 10) |
|
215 |
me.screenElements.Speed110 |
|
216 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
|
217 |
else |
|
218 |
me.screenElements.Speed110 |
|
219 |
.setText(''); |
|
220 |
me.screenElements.SpeedLint1 |
|
221 |
.setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36); |
|
222 |
me.screenElements.SpeedTape |
|
223 |
.setTranslation(0,ias * 5.711); |
|
224 |
settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1); |
|
225 |
}, |
|
animation ALT
|
226 | |
227 |
updateALT: func (alt) { |
|
228 |
if (alt < 0) |
|
229 |
me.screenElements.Alt11100 |
|
230 |
.setText(sprintf("% 3i",math.ceil(alt/100))); |
|
231 |
elsif (alt < 100) |
|
232 |
me.screenElements.Alt11100 |
|
233 |
.setText(''); |
|
234 |
else |
|
235 |
me.screenElements.Alt11100 |
|
236 |
.setText(sprintf("% 3i",math.floor(alt/100))); |
|
237 |
me.screenElements.AltLint00011 |
|
238 |
.setTranslation(0,math.fmod(alt,100) * 1.24); |
|
239 | ||
240 |
# From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000 |
|
241 |
if (alt> -1000 and alt< 1000000) { |
|
242 |
var Offset10 = 0; |
|
243 |
var Offset100 = 0; |
|
244 |
var Offset1000 = 0; |
|
245 |
if (alt< 0) { |
|
246 |
var Ne = 1; |
|
247 |
var alt= -alt; |
|
248 |
} |
|
249 |
else |
|
250 |
var Ne = 0; |
|
251 | ||
252 |
var Alt10 = math.mod(alt,100); |
|
253 |
var Alt100 = int(math.mod(alt/100,10)); |
|
254 |
var Alt1000 = int(math.mod(alt/1000,10)); |
|
255 |
var Alt10000 = int(math.mod(alt/10000,10)); |
|
256 |
var Alt20 = math.mod(Alt10,20)/20; |
|
257 |
if (Alt10 >= 80) |
|
258 |
var Alt100 += Alt20; |
|
259 | ||
260 |
if (Alt10 >= 80 and Alt100 >= 9) |
|
261 |
var Alt1000 += Alt20; |
|
262 | ||
263 |
if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9) |
|
264 |
var Alt10000 += Alt20; |
|
265 | ||
266 |
if (alt> 100) |
|
267 |
var Offset10 = 100; |
|
268 | ||
269 |
if (alt> 1000) |
|
270 |
var Offset100 = 10; |
|
271 | ||
272 |
if (alt> 10000) |
|
273 |
var Offset1000 = 10; |
|
274 | ||
275 |
if (!Ne) { |
|
276 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375); |
|
277 |
var altCentral = (int(alt/100)*100); |
|
278 |
} |
|
279 |
elsif (Ne) { |
|
280 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375); |
|
281 |
var altCentral = -(int(alt/100)*100); |
|
282 |
} |
|
283 |
me.screenElements["AltBigC"].setText(""); |
|
284 |
me.screenElements["AltSmallC"].setText(""); |
|
285 |
for (var place = 1; place <= 6; place += 1) { |
|
286 |
var altUP = altCentral + (place*100); |
|
287 |
var offset = -30.078; |
|
288 |
if (altUP < 0) { |
|
289 |
var altUP = -altUP; |
|
290 |
var prefix = "-"; |
|
291 |
var offset += 15.039; |
|
292 |
} |
|
293 |
else |
|
294 |
var prefix = ""; |
|
295 | ||
296 |
if (altUP == 0) { |
|
297 |
var AltBigUP = ""; |
|
298 |
var AltSmallUP = "0"; |
|
299 | ||
300 |
} |
|
301 |
elsif (math.mod(altUP,500) == 0 and altUP != 0) { |
|
302 |
var AltBigUP = sprintf(prefix~"%1d", altUP); |
|
303 |
var AltSmallUP = ""; |
|
304 |
} |
|
305 |
elsif (altUP < 1000 and (math.mod(altUP,500))) { |
|
306 |
var AltBigUP = ""; |
|
307 |
var AltSmallUP = sprintf(prefix~"%1d", int(math.mod(altUP,1000))); |
|
308 |
var offset = -30.078; |
|
309 |
} |
|
310 |
elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) { |
|
311 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
312 |
var AltSmallUP = sprintf("%1d", int(math.mod(altUP,1000))); |
|
313 |
var offset += 15.039; |
|
314 |
} |
|
315 |
else { |
|
316 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
317 |
var mod = int(math.mod(altUP,1000)); |
|
318 |
var AltSmallUP = sprintf("%1d", mod); |
|
319 |
var offset += 30.078; |
|
320 |
} |
|
321 | ||
322 |
me.screenElements["AltBigU"~place].setText(AltBigUP); |
|
323 |
me.screenElements["AltSmallU"~place].setText(AltSmallUP); |
|
324 |
me.screenElements["AltSmallU"~place].setTranslation(offset,0); |
|
325 |
var altDOWN = altCentral - (place*100); |
|
326 |
var offset = -30.078; |
|
327 |
if (altDOWN < 0) { |
|
328 |
var altDOWN = -altDOWN; |
|
329 |
var prefix = "-"; |
|
330 |
var offset += 15.039; |
|
331 |
} |
|
332 |
else |
|
333 |
var prefix = ""; |
|
334 | ||
335 |
if (altDOWN == 0) { |
|
336 |
var AltBigDOWN = ""; |
|
337 |
var AltSmallDOWN = "0"; |
|
338 |
} |
|
339 |
elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) { |
|
340 |
var AltBigDOWN = sprintf(prefix~"%1d", altDOWN); |
|
341 |
var AltSmallDOWN = ""; |
|
342 |
} |
|
343 |
elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) { |
|
344 |
var AltBigDOWN = ""; |
|
345 |
var AltSmallDOWN = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000))); |
|
346 |
var offset = -30.078; |
|
347 |
} |
|
348 |
elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) { |
|
349 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
350 |
var AltSmallDOWN = sprintf("%1d", int(math.mod(altDOWN,1000))); |
|
351 |
var offset += 15.039; |
|
352 |
} |
|
353 |
else { |
|
354 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
355 |
var mod = int(math.mod(altDOWN,1000)); |
|
356 |
var AltSmallDOWN = sprintf("%1d", mod); |
|
357 |
var offset += 30.078; |
|
358 |
} |
|
359 |
me.screenElements["AltBigD"~place].setText(AltBigDOWN); |
|
360 |
me.screenElements["AltSmallD"~place].setText(AltSmallDOWN); |
|
361 |
me.screenElements["AltSmallD"~place].setTranslation(offset,0); |
|
362 |
} |
|
363 |
} |
|
364 |
settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2); |
|
365 |
}, |
|
animation HSI
|
366 | |
367 |
updateHSI : func (hdg) { |
|
368 |
me.screenElements.Rose |
|
369 |
.setRotation(-hdg * D2R); |
|
370 |
me.screenElements['HDG-text'] |
|
371 |
.setText(sprintf("%03u°", hdg)); |
|
372 |
settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1); |
|
373 |
}, |
|
commit initial
|
374 |
}; |