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 |
} |
|
clean pre-merge
|
146 |
# else |
147 |
# print('no text format for ' ~ e); |
|
animation VSI
|
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 : { |
|
clean pre-merge
|
169 |
PitchScale : "rect(70,664,370,256)", |
170 |
SpeedLint1 : "rect(252,226,318,204)", |
|
171 |
SpeedTape : "rect(115,239,455,156)", |
|
172 |
LintAlt : "rect(115,808,455,704)", |
|
animation ALT
|
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 |
}, |
|
clean pre-merge
|
186 |
"HDG-text" : { |
187 |
default: '---°' |
|
188 |
}, |
|
animation VSI
|
189 |
}, |
190 | ||
AI disponible, avec bankPoin...
|
191 |
updateAI: func(roll,pitch){ |
AI disponible
|
192 |
if (pitch > 80) |
193 |
pitch = 80; |
|
clean pre-merge
|
194 |
elsif (pitch < -80) |
AI disponible
|
195 |
pitch = -80; |
196 |
me.screenElements.Horizon |
|
197 |
.setRotation(-roll * D2R) |
|
198 |
.setTranslation(0, pitch * 6.8571428); |
|
AI disponible, avec bankPoin...
|
199 |
me.screenElements.bankPointer |
200 |
.setRotation(-roll * D2R); |
|
201 |
settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1); |
|
AI disponible
|
202 |
}, |
animation VSI
|
203 | |
204 |
updateVSI: func (vsi) { |
|
205 |
me.screenElements.VSIText |
|
206 |
.setText(num(math.round(vsi, 10))); |
|
207 |
if (vsi > 4500) |
|
208 |
vsi = 4500; |
|
209 |
elsif (vsi < -4500) |
|
210 |
vsi = -4500; |
|
211 |
me.screenElements.VSI |
|
212 |
.setTranslation(0, vsi * -0.03465); |
|
213 |
settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1); |
|
214 |
}, |
|
animation IAS
|
215 | |
216 |
updateIAS: func (ias) { |
|
217 |
if (ias >= 10) |
|
218 |
me.screenElements.Speed110 |
|
219 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
|
220 |
else |
|
221 |
me.screenElements.Speed110 |
|
222 |
.setText(''); |
|
223 |
me.screenElements.SpeedLint1 |
|
224 |
.setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36); |
|
225 |
me.screenElements.SpeedTape |
|
226 |
.setTranslation(0,ias * 5.711); |
|
227 |
settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1); |
|
228 |
}, |
|
animation ALT
|
229 | |
230 |
updateALT: func (alt) { |
|
231 |
if (alt < 0) |
|
232 |
me.screenElements.Alt11100 |
|
233 |
.setText(sprintf("% 3i",math.ceil(alt/100))); |
|
234 |
elsif (alt < 100) |
|
235 |
me.screenElements.Alt11100 |
|
236 |
.setText(''); |
|
237 |
else |
|
238 |
me.screenElements.Alt11100 |
|
239 |
.setText(sprintf("% 3i",math.floor(alt/100))); |
|
240 |
me.screenElements.AltLint00011 |
|
241 |
.setTranslation(0,math.fmod(alt,100) * 1.24); |
|
242 | ||
243 |
# From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000 |
|
244 |
if (alt> -1000 and alt< 1000000) { |
|
245 |
var Offset10 = 0; |
|
246 |
var Offset100 = 0; |
|
247 |
var Offset1000 = 0; |
|
248 |
if (alt< 0) { |
|
249 |
var Ne = 1; |
|
250 |
var alt= -alt; |
|
251 |
} |
|
252 |
else |
|
253 |
var Ne = 0; |
|
254 | ||
255 |
var Alt10 = math.mod(alt,100); |
|
256 |
var Alt100 = int(math.mod(alt/100,10)); |
|
257 |
var Alt1000 = int(math.mod(alt/1000,10)); |
|
258 |
var Alt10000 = int(math.mod(alt/10000,10)); |
|
259 |
var Alt20 = math.mod(Alt10,20)/20; |
|
260 |
if (Alt10 >= 80) |
|
261 |
var Alt100 += Alt20; |
|
262 | ||
263 |
if (Alt10 >= 80 and Alt100 >= 9) |
|
264 |
var Alt1000 += Alt20; |
|
265 | ||
266 |
if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9) |
|
267 |
var Alt10000 += Alt20; |
|
268 | ||
269 |
if (alt> 100) |
|
270 |
var Offset10 = 100; |
|
271 | ||
272 |
if (alt> 1000) |
|
273 |
var Offset100 = 10; |
|
274 | ||
275 |
if (alt> 10000) |
|
276 |
var Offset1000 = 10; |
|
277 | ||
278 |
if (!Ne) { |
|
279 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375); |
|
280 |
var altCentral = (int(alt/100)*100); |
|
281 |
} |
|
282 |
elsif (Ne) { |
|
283 |
me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375); |
|
284 |
var altCentral = -(int(alt/100)*100); |
|
285 |
} |
|
286 |
me.screenElements["AltBigC"].setText(""); |
|
287 |
me.screenElements["AltSmallC"].setText(""); |
|
288 |
for (var place = 1; place <= 6; place += 1) { |
|
289 |
var altUP = altCentral + (place*100); |
|
290 |
var offset = -30.078; |
|
291 |
if (altUP < 0) { |
|
292 |
var altUP = -altUP; |
|
293 |
var prefix = "-"; |
|
294 |
var offset += 15.039; |
|
295 |
} |
|
296 |
else |
|
297 |
var prefix = ""; |
|
298 | ||
299 |
if (altUP == 0) { |
|
300 |
var AltBigUP = ""; |
|
301 |
var AltSmallUP = "0"; |
|
302 | ||
303 |
} |
|
304 |
elsif (math.mod(altUP,500) == 0 and altUP != 0) { |
|
305 |
var AltBigUP = sprintf(prefix~"%1d", altUP); |
|
306 |
var AltSmallUP = ""; |
|
307 |
} |
|
308 |
elsif (altUP < 1000 and (math.mod(altUP,500))) { |
|
309 |
var AltBigUP = ""; |
|
310 |
var AltSmallUP = sprintf(prefix~"%1d", int(math.mod(altUP,1000))); |
|
311 |
var offset = -30.078; |
|
312 |
} |
|
313 |
elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) { |
|
314 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
315 |
var AltSmallUP = sprintf("%1d", int(math.mod(altUP,1000))); |
|
316 |
var offset += 15.039; |
|
317 |
} |
|
318 |
else { |
|
319 |
var AltBigUP = sprintf(prefix~"%1d", int(altUP/1000)); |
|
320 |
var mod = int(math.mod(altUP,1000)); |
|
321 |
var AltSmallUP = sprintf("%1d", mod); |
|
322 |
var offset += 30.078; |
|
323 |
} |
|
324 | ||
325 |
me.screenElements["AltBigU"~place].setText(AltBigUP); |
|
326 |
me.screenElements["AltSmallU"~place].setText(AltSmallUP); |
|
327 |
me.screenElements["AltSmallU"~place].setTranslation(offset,0); |
|
328 |
var altDOWN = altCentral - (place*100); |
|
329 |
var offset = -30.078; |
|
330 |
if (altDOWN < 0) { |
|
331 |
var altDOWN = -altDOWN; |
|
332 |
var prefix = "-"; |
|
333 |
var offset += 15.039; |
|
334 |
} |
|
335 |
else |
|
336 |
var prefix = ""; |
|
337 | ||
338 |
if (altDOWN == 0) { |
|
339 |
var AltBigDOWN = ""; |
|
340 |
var AltSmallDOWN = "0"; |
|
341 |
} |
|
342 |
elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) { |
|
343 |
var AltBigDOWN = sprintf(prefix~"%1d", altDOWN); |
|
344 |
var AltSmallDOWN = ""; |
|
345 |
} |
|
346 |
elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) { |
|
347 |
var AltBigDOWN = ""; |
|
348 |
var AltSmallDOWN = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000))); |
|
349 |
var offset = -30.078; |
|
350 |
} |
|
351 |
elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) { |
|
352 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
353 |
var AltSmallDOWN = sprintf("%1d", int(math.mod(altDOWN,1000))); |
|
354 |
var offset += 15.039; |
|
355 |
} |
|
356 |
else { |
|
357 |
var AltBigDOWN = sprintf(prefix~"%1d", int(altDOWN/1000)); |
|
358 |
var mod = int(math.mod(altDOWN,1000)); |
|
359 |
var AltSmallDOWN = sprintf("%1d", mod); |
|
360 |
var offset += 30.078; |
|
361 |
} |
|
362 |
me.screenElements["AltBigD"~place].setText(AltBigDOWN); |
|
363 |
me.screenElements["AltSmallD"~place].setText(AltSmallDOWN); |
|
364 |
me.screenElements["AltSmallD"~place].setTranslation(offset,0); |
|
365 |
} |
|
366 |
} |
|
367 |
settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2); |
|
368 |
}, |
|
animation HSI
|
369 | |
370 |
updateHSI : func (hdg) { |
|
371 |
me.screenElements.Rose |
|
372 |
.setRotation(-hdg * D2R); |
|
373 |
me.screenElements['HDG-text'] |
|
374 |
.setText(sprintf("%03u°", hdg)); |
|
375 |
settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1); |
|
376 |
}, |
|
commit initial
|
377 |
}; |