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', |
47 |
], |
|
animation IAS
|
48 |
text: [ |
49 |
'VSIText', |
|
50 |
'Speed110' |
|
51 |
], |
|
52 |
clip: [ |
|
53 |
'SpeedLint1', |
|
54 |
'SpeedTape' |
|
55 |
], |
|
animation VSI
|
56 |
}); |
animation IAS
|
57 | |
AI disponible, avec bankPoin...
|
58 |
me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')); |
animation VSI
|
59 |
me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')); |
animation IAS
|
60 |
me.updateIAS(getprop('/velocities/airspeed-kt')); |
commit initial
|
61 |
me.progress.removeAllChildren(); |
62 |
me.progress = nil; |
|
63 |
me.showInitProgress = nil; |
|
64 |
me._showInitProgress = nil; |
|
65 |
zkv.removeChild(me.role ~ 'init'); |
|
66 |
} |
|
67 |
}, |
|
68 | ||
69 |
showInitProgress : func (role) { |
|
70 |
me.progress = me.display.createGroup(); |
|
71 |
me.progress.show(); |
|
72 |
me.progress.createChild("text", role ~ " title") |
|
73 |
.setTranslation(512, 384) |
|
74 |
.setAlignment("center-center") |
|
75 |
.setFont("LiberationFonts/LiberationSans-Italic.ttf") |
|
76 |
.setFontSize(64, 1) |
|
77 |
.setColor(1,1,1) |
|
78 |
.setText("ZKV1000 " ~ role ~ " init"); |
|
79 | ||
80 |
zkv.getNode(role ~ 'init',1).setIntValue(1); |
|
81 | ||
82 |
me._showInitProgress(me.progress.createChild("text", role ~ "progress") |
|
83 |
.setTranslation(512, 484) |
|
84 |
.setAlignment("center-center") |
|
85 |
.setFont("LiberationFonts/LiberationSans-Bold.ttf") |
|
86 |
.setFontSize(128, 1) |
|
87 |
.setColor(1,0,0), '.'); |
|
88 |
}, |
|
89 | ||
écriture du wrapper pour le ...
|
90 |
loadGroup : func (h) { |
91 |
if (typeof(h) != 'hash') { |
|
92 |
msg_dbg(sprintf("%s need a hash, but get a %s from %s", |
|
93 |
caller(0)[0], |
|
94 |
typeof(h), |
|
95 |
caller(1)[0])); |
|
96 |
return; |
|
commit initial
|
97 |
} |
écriture du wrapper pour le ...
|
98 |
var setMethod = func (e, t) { |
99 |
if (t == 'hide') |
|
100 |
me.screenElements[e].hide(); |
|
101 |
elsif (t == 'show') |
|
102 |
me.screenElements[e].show(); |
|
AI disponible
|
103 |
elsif (t == 'rot' or t == 'trans') { |
104 |
if (! contains(me.screenElements[e], t)) |
|
105 |
me.screenElements[e][t] = me.screenElements[e].createTransform(); |
|
106 |
} |
|
107 |
elsif (t == 'clip') { |
|
108 |
if (contains(me.clips, e)) |
|
109 |
me.screenElements[e].set("clip", me.clips[e]); |
|
110 |
else |
|
111 |
print('no defined clip for ' ~ e); |
|
112 |
} |
|
animation VSI
|
113 |
elsif (t == 'text') { |
114 |
if (contains(me.texts, e)) { |
|
115 |
if (contains(me.texts[e], 'alignment')) |
|
116 |
me.screenElements[e].setAlignment(me.texts[e].alignment); |
|
117 |
if (contains(me.texts[e], 'default')) |
|
118 |
me.screenElements[e].setText(me.texts[e].default); |
|
119 |
} |
|
120 |
else |
|
121 |
print('no alignment for ' ~ e); |
|
122 |
} |
|
commit initial
|
123 |
else |
écriture du wrapper pour le ...
|
124 |
print('unknown method ' ~ t); |
125 |
}; |
|
126 |
foreach (var todo; keys(h)) { |
|
127 |
if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ]; |
|
128 |
foreach (var id; h[todo]) { |
|
129 |
if (! contains(me.screenElements, id)) { |
|
130 |
me.screenElements[id] = me.screen.getElementById(id); |
|
131 |
if (me.screenElements[id] != nil) |
|
132 |
setMethod(id, todo); |
|
133 |
else |
|
134 |
print('SVG ID ' ~ id ~ ' not found'); |
|
135 |
} |
|
136 |
else |
|
137 |
setMethod(id, todo); |
|
138 |
} |
|
commit initial
|
139 |
} |
140 |
}, |
|
AI disponible
|
141 | |
142 |
clips : { |
|
143 |
PitchScale : "rect(70,664,370,256)", |
|
animation IAS
|
144 |
SpeedLint1 : "rect(252,226,318,204)", |
145 |
SpeedTape : "rect(115,239,455,156)", |
|
AI disponible
|
146 |
}, |
147 | ||
animation VSI
|
148 |
texts : { |
149 |
VSIText : { |
|
150 |
alignment: "right-bottom", default : num('0'), |
|
151 |
}, |
|
animation IAS
|
152 |
Speed110 : { |
153 |
default: '', alignment : 'left-bottom' |
|
154 |
}, |
|
animation VSI
|
155 |
}, |
156 | ||
AI disponible, avec bankPoin...
|
157 |
updateAI: func(roll,pitch){ |
AI disponible
|
158 |
if (pitch > 80) |
159 |
pitch = 80; |
|
160 |
elsif(pitch < -80) |
|
161 |
pitch = -80; |
|
162 |
me.screenElements.Horizon |
|
163 |
.setRotation(-roll * D2R) |
|
164 |
.setTranslation(0, pitch * 6.8571428); |
|
AI disponible, avec bankPoin...
|
165 |
me.screenElements.bankPointer |
166 |
.setRotation(-roll * D2R); |
|
167 |
settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1); |
|
AI disponible
|
168 |
}, |
animation VSI
|
169 | |
170 |
updateVSI: func (vsi) { |
|
171 |
me.screenElements.VSIText |
|
172 |
.setText(num(math.round(vsi, 10))); |
|
173 |
if (vsi > 4500) |
|
174 |
vsi = 4500; |
|
175 |
elsif (vsi < -4500) |
|
176 |
vsi = -4500; |
|
177 |
me.screenElements.VSI |
|
178 |
.setTranslation(0, vsi * -0.03465); |
|
179 |
settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1); |
|
180 |
}, |
|
animation IAS
|
181 | |
182 |
updateIAS: func (ias) { |
|
183 |
if (ias >= 10) |
|
184 |
me.screenElements.Speed110 |
|
185 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
|
186 |
else |
|
187 |
me.screenElements.Speed110 |
|
188 |
.setText(''); |
|
189 |
me.screenElements.SpeedLint1 |
|
190 |
.setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36); |
|
191 |
me.screenElements.SpeedTape |
|
192 |
.setTranslation(0,ias * 5.711); |
|
193 |
settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1); |
|
194 |
}, |
|
commit initial
|
195 |
}; |