zkv1000 / Nasal / display.nas /
Newer Older
571 lines | 21.251kb
commit initial
Sébastien MARQUE authored on 2017-03-07
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 ...
Sébastien MARQUE authored on 2017-03-10
17
        m.screenElements = {};
commit initial
Sébastien MARQUE authored on 2017-03-07
18

            
19
        return m;
20
    },
21

            
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
22
    timers : {},
23

            
24
    timerTrigger : func {
25
        var now = systime();
26
        foreach (var id; keys(me.timers)) {
27
            if (me.timers[id] < now) {
28
                me.screenElements[id].hide();
29
                delete(me.timers, id);
30
            }
31
        }
32
        settimer(func me.timerTrigger(), 1);
33
    },
34

            
35
    addTimer : func (duration, element) {
36
        if (typeof(element) == 'scalar')
37
            element = [ element ];
38
        var end = systime() + duration;
39
        foreach (var e; element)
40
            me.timers[e] = end;
41
    },
42

            
commit initial
Sébastien MARQUE authored on 2017-03-07
43
    loadsvg : func () {
44
        me.screen = me.display.createGroup();
45
        me.screen.hide();
46
        canvas.parsesvg(me.screen, "Aircraft/Instruments-3d/zkv1000/Systems/screen.svg");
47
    },
48

            
49
    _showInitProgress : func (p,t) {
50
        p.setText(t);
51
        if (zkv.getNode(me.role ~ 'init').getValue() != 0) {
52
            if (size(t) >= 10) t = '';
53
            settimer(func { me._showInitProgress(p, t ~ '.'); }, 0.1);
54
        }
55
        else {
56
            me.progress.hide();
57
            me.screen.show();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
58
            var groups = {
animation VSI
Sébastien MARQUE authored on 2017-03-10
59
                show : [
commit initial
Sébastien MARQUE authored on 2017-03-07
60
                    'SoftKeysTexts', 
61
                    'COMM', 
62
                    'NAV', 
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
63
                    'nav-freq-switch',
64
                    'comm-freq-switch',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
65
                ],
66
                text: [
67
                    'nav1-standby-freq', 'nav1-selected-freq', 'nav1-id',
68
                    'nav2-standby-freq', 'nav2-selected-freq', 'nav2-id',
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
69
                    'comm1-standby-freq', 'comm1-selected-freq',
70
                    'comm2-standby-freq', 'comm2-selected-freq',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
71
                ],
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
72
                hide : [ ],
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
73
                clip: [ ],
74
            };
75
            if (me.role == 'PFD') {
76
                append(groups.show,
commit initial
Sébastien MARQUE authored on 2017-03-07
77
                    'XPDR-TIME', 
AI disponible
Sébastien MARQUE authored on 2017-03-10
78
                    'FlightInstruments',
79
                    'Horizon',
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
80
                    'bankPointer',
animation VSI
Sébastien MARQUE authored on 2017-03-10
81
                    'VSI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
82
                    'Rose',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
83
                    'Heading-bug',
84
                    'PFD-Widgets',
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
85
                );
86
                append(groups.hide,
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
87
                    'CDI',
animation HSI
Sébastien MARQUE authored on 2017-03-11
88
                    'NAV1-pointer',
89
                    'NAV2-pointer',
90
                    'GPS-pointer',
91
                    'Bearing1',
92
                    'Bearing2',
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
93
                    'SelectedHDG-bg',
94
                    'SelectedHDG-bgtext',
95
                    'SelectedHDG-text',
96
                    'SelectedCRS-bg',
97
                    'SelectedCRS-bgtext',
98
                    'SelectedCRS-text',
99
                    'SelectedALT',
100
                    'TAS',
101
                    'GSPD',
102
                    'OAT',
103
                    'BARO',
104
                    'WindData',
105
                    'Reversionnary',
106
                    'Annunciation',
107
                    'Comparator',
108
                    'BRG1',
109
                    'BRG2',
110
                    'DME1',
111
                    'PFD-Map',
112
                    'PFD-Multilines'
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
113
                );
114
                append(groups.clip,
animation IAS
Sébastien MARQUE authored on 2017-03-10
115
                    'SpeedLint1',
animation ALT
Sébastien MARQUE authored on 2017-03-11
116
                    'SpeedTape',
117
                    'LintAlt',
118
                    'AltLint00011'
119
                );
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
120
                append(groups.text,
121
                    'VSIText',
122
                    'Speed110',
123
                    'Alt11100',
124
                    'HDG-text',
125
                    'AltBigC', 'AltSmallC'
126
                );
127
                for (var place = 1; place <= 6; place +=1) {
128
                    append(groups.text,
129
                        'AltBigU' ~ place,
130
                        'AltSmallU' ~ place,
131
                        'AltBigD' ~ place,
132
                        'AltSmallD' ~ place
133
                    );
134
                }
animation ALT
Sébastien MARQUE authored on 2017-03-11
135
            }
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
136
            else
137
                append(groups.show, 'Header');
138

            
139
            me.loadGroup(groups);
animation ALT
Sébastien MARQUE authored on 2017-03-11
140

            
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
141
            if (me.role == 'PFD') {
142
                me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg'));
143
                me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm'));
144
                me.updateIAS(getprop('/velocities/airspeed-kt'));
145
                me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft'));
146
                me.updateHSI(getprop('orientation/heading-deg'));
ajoute un timer pour cacher ...
Sébastien MARQUE authored on 2017-03-13
147
                me.timerTrigger();
séparation configuration PFD...
Sébastien MARQUE authored on 2017-03-12
148
            }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
149
            me._updateRadio({auto:'nav'});
150
            me._updateRadio({auto:'comm'});
commit initial
Sébastien MARQUE authored on 2017-03-07
151
            me.progress.removeAllChildren();
152
            me.progress = nil;
153
            me.showInitProgress = nil;
154
            me._showInitProgress = nil;
155
            zkv.removeChild(me.role ~ 'init');
156
        }
157
    },
158

            
159
    showInitProgress : func (role) {
160
        me.progress = me.display.createGroup();
161
        me.progress.show();
162
        me.progress.createChild("text", role ~ " title")
163
            .setTranslation(512, 384)
164
            .setAlignment("center-center")
165
            .setFont("LiberationFonts/LiberationSans-Italic.ttf")
166
            .setFontSize(64, 1)
167
            .setColor(1,1,1)
168
            .setText("ZKV1000 " ~ role ~ " init");
169

            
170
        zkv.getNode(role ~ 'init',1).setIntValue(1);
171

            
172
        me._showInitProgress(me.progress.createChild("text", role ~ "progress")
173
            .setTranslation(512, 484)
174
            .setAlignment("center-center")
175
            .setFont("LiberationFonts/LiberationSans-Bold.ttf")
176
            .setFontSize(128, 1)
177
            .setColor(1,0,0), '.');
178
    },
179

            
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
180
    loadGroup : func (h) {
181
        if (typeof(h) != 'hash') {
182
            msg_dbg(sprintf("%s need a hash, but get a %s from %s",
183
                    caller(0)[0],
184
                    typeof(h),
185
                    caller(1)[0]));
186
            return;
commit initial
Sébastien MARQUE authored on 2017-03-07
187
        }
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
188
        var setMethod = func (e, t) {
189
            if (t == 'hide')
190
                me.screenElements[e].hide();
191
            elsif (t == 'show')
192
                me.screenElements[e].show();
AI disponible
Sébastien MARQUE authored on 2017-03-10
193
            elsif (t == 'rot' or t == 'trans') {
194
                if (! contains(me.screenElements[e], t))
195
                    me.screenElements[e][t] = me.screenElements[e].createTransform();
196
            }
197
            elsif (t == 'clip') {
198
                if (contains(me.clips, e))
199
                    me.screenElements[e].set("clip", me.clips[e]);
200
                else
201
                    print('no defined clip for ' ~ e);
202
            }
animation VSI
Sébastien MARQUE authored on 2017-03-10
203
            elsif (t == 'text') {
204
                if (contains(me.texts, e)) {
205
                    if (contains(me.texts[e], 'alignment'))
206
                        me.screenElements[e].setAlignment(me.texts[e].alignment);
207
                    if (contains(me.texts[e], 'default'))
208
                        me.screenElements[e].setText(me.texts[e].default);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
209
                    if (contains(me.texts[e], 'color'))
210
                        me.screenElements[e].setColor(me.texts[e].color);
animation VSI
Sébastien MARQUE authored on 2017-03-10
211
                }
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
212
#                else
213
#                    print('no text format for ' ~ e);
animation VSI
Sébastien MARQUE authored on 2017-03-10
214
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
215
            else
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
216
                print('unknown method ' ~ t);
217
        };
218
        foreach (var todo; keys(h)) {
219
            if (typeof(h[todo]) != 'vector') h[todo] = [ h[todo] ];
220
            foreach (var id; h[todo]) {
221
                if (! contains(me.screenElements, id)) {
222
                    me.screenElements[id] = me.screen.getElementById(id);
223
                    if (me.screenElements[id] != nil)
224
                        setMethod(id, todo);
225
                    else
226
                        print('SVG ID ' ~ id ~ ' not found');
227
                }
228
                else
229
                    setMethod(id, todo);
230
            }
commit initial
Sébastien MARQUE authored on 2017-03-07
231
        }
232
    },
AI disponible
Sébastien MARQUE authored on 2017-03-10
233

            
234
    clips : {
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
235
        PitchScale   : "rect(70,664,370,256)",
236
        SpeedLint1   : "rect(252,226,318,204)",
237
        SpeedTape    : "rect(115,239,455,156)",
238
        LintAlt      : "rect(115,808,455,704)",
animation ALT
Sébastien MARQUE authored on 2017-03-11
239
        AltLint00011 : "rect(252,804,318,771)",
AI disponible
Sébastien MARQUE authored on 2017-03-10
240
    },
241

            
animation VSI
Sébastien MARQUE authored on 2017-03-10
242
    texts : {
243
        VSIText : {
244
            alignment: "right-bottom", default : num('0'),
245
        },
animation IAS
Sébastien MARQUE authored on 2017-03-10
246
        Speed110 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
247
            alignment : 'left-bottom'
animation IAS
Sébastien MARQUE authored on 2017-03-10
248
        },
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
249
        Alt11100 : {
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
250
            alignment:'left-bottom'
animation ALT (2)
Sébastien MARQUE authored on 2017-03-11
251
        },
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
252
        "HDG-text" : {
253
            default: '---°'
254
        },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
255
        'nav1-standby-freq' : {
256
            color: [0, 1, 1],
257
        },
258
        'nav1-id' : {
259
            default: ''
260
        },
261
        'nav2-id' : {
262
            default: ''
263
        },
animation VSI
Sébastien MARQUE authored on 2017-03-10
264
    },
265

            
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
266
    updateAI: func(roll,pitch){
AI disponible
Sébastien MARQUE authored on 2017-03-10
267
        if (pitch > 80)
268
            pitch = 80;
clean pre-merge
Sébastien MARQUE authored on 2017-03-11
269
        elsif (pitch < -80)
AI disponible
Sébastien MARQUE authored on 2017-03-10
270
            pitch = -80;
271
        me.screenElements.Horizon
272
            .setRotation(-roll * D2R)
273
            .setTranslation(0, pitch * 6.8571428);
AI disponible, avec bankPoin...
Sébastien MARQUE authored on 2017-03-10
274
        me.screenElements.bankPointer
275
            .setRotation(-roll * D2R);
276
        settimer(func me.updateAI(getprop('/orientation/roll-deg'),getprop('orientation/pitch-deg')), 0.1);
AI disponible
Sébastien MARQUE authored on 2017-03-10
277
    },
animation VSI
Sébastien MARQUE authored on 2017-03-10
278

            
279
    updateVSI: func (vsi) {
280
        me.screenElements.VSIText
281
            .setText(num(math.round(vsi, 10)));
282
        if (vsi > 4500)
283
            vsi = 4500;
284
        elsif (vsi < -4500)
285
            vsi = -4500;
286
        me.screenElements.VSI
287
            .setTranslation(0, vsi * -0.03465);
288
        settimer(func me.updateVSI(getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm')), 0.1);
289
    },
animation IAS
Sébastien MARQUE authored on 2017-03-10
290

            
291
    updateIAS: func (ias) {
292
        if (ias >= 10)
293
            me.screenElements.Speed110
294
                .setText(sprintf("% 2u",num(math.floor(ias/10))));
295
        else
296
            me.screenElements.Speed110
297
                .setText('');
298
        me.screenElements.SpeedLint1
299
            .setTranslation(0,(math.mod(ias,10) + (ias >= 10)*10) * 36);
300
        me.screenElements.SpeedTape
301
            .setTranslation(0,ias * 5.711);
302
        settimer(func me.updateIAS(getprop('/velocities/airspeed-kt')), 0.1);
303
    },
animation ALT
Sébastien MARQUE authored on 2017-03-11
304

            
305
    updateALT: func (alt) {
306
        if (alt < 0)
307
            me.screenElements.Alt11100
308
                .setText(sprintf("% 3i",math.ceil(alt/100)));
309
        elsif (alt < 100)
310
            me.screenElements.Alt11100
311
                .setText('');
312
        else
313
            me.screenElements.Alt11100
314
                .setText(sprintf("% 3i",math.floor(alt/100)));
315
        me.screenElements.AltLint00011
316
            .setTranslation(0,math.fmod(alt,100) * 1.24);
317

            
318
        # From Farmin/G1000 http://wiki.flightgear.org/Project_Farmin/FG1000
319
        if (alt> -1000 and alt< 1000000) {
320
            var Offset10 = 0;
321
            var Offset100 = 0;
322
            var Offset1000 = 0;
323
            if (alt< 0) {
324
                var Ne = 1;
325
                var alt= -alt;
326
            }
327
            else
328
                var Ne = 0;
329

            
330
            var Alt10       = math.mod(alt,100);
331
            var Alt100      = int(math.mod(alt/100,10));
332
            var Alt1000     = int(math.mod(alt/1000,10));
333
            var Alt10000    = int(math.mod(alt/10000,10));
334
            var Alt20       = math.mod(Alt10,20)/20;
335
            if (Alt10 >= 80)
336
                var Alt100 += Alt20;
337

            
338
            if (Alt10 >= 80 and Alt100 >= 9)
339
                var Alt1000 += Alt20;
340

            
341
            if (Alt10 >= 80 and Alt100 >= 9 and Alt1000 >= 9)
342
                var Alt10000 += Alt20;
343

            
344
            if (alt> 100)
345
                var Offset10 = 100;
346

            
347
            if (alt> 1000)
348
                var Offset100 = 10;
349

            
350
            if (alt> 10000)
351
                var Offset1000 = 10;
352

            
353
            if (!Ne) {
354
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*0.57375);
355
                var altCentral = (int(alt/100)*100);
356
            }
357
            elsif (Ne) {
358
                me.screenElements.LintAlt.setTranslation(0,(math.mod(alt,100))*-0.57375);
359
                var altCentral = -(int(alt/100)*100);
360
            }
361
            me.screenElements["AltBigC"].setText("");
362
            me.screenElements["AltSmallC"].setText("");
363
            for (var place = 1; place <= 6; place += 1) {
364
                var altUP = altCentral + (place*100);
365
                var offset = -30.078;
366
                if (altUP < 0) {
367
                    var altUP = -altUP;
368
                    var prefix = "-";
369
                    var offset += 15.039;
370
                }
371
                else
372
                    var prefix = "";
373

            
374
                if (altUP == 0) {
375
                    var AltBigUP    = "";
376
                    var AltSmallUP  = "0";
377

            
378
                }
379
                elsif (math.mod(altUP,500) == 0 and altUP != 0) {
380
                    var AltBigUP    = sprintf(prefix~"%1d", altUP);
381
                    var AltSmallUP  = "";
382
                }
383
                elsif (altUP < 1000 and (math.mod(altUP,500))) {
384
                    var AltBigUP    = "";
385
                    var AltSmallUP  = sprintf(prefix~"%1d", int(math.mod(altUP,1000)));
386
                    var offset = -30.078;
387
                }
388
                elsif ((altUP < 10000) and (altUP >= 1000) and (math.mod(altUP,500))) {
389
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
390
                    var AltSmallUP  = sprintf("%1d", int(math.mod(altUP,1000)));
391
                    var offset += 15.039;
392
                }
393
                else {
394
                    var AltBigUP    = sprintf(prefix~"%1d", int(altUP/1000));
395
                    var mod = int(math.mod(altUP,1000));
396
                    var AltSmallUP  = sprintf("%1d", mod);
397
                    var offset += 30.078;
398
                }
399

            
400
                me.screenElements["AltBigU"~place].setText(AltBigUP);
401
                me.screenElements["AltSmallU"~place].setText(AltSmallUP);
402
                me.screenElements["AltSmallU"~place].setTranslation(offset,0);
403
                var altDOWN = altCentral - (place*100);
404
                var offset = -30.078;
405
                if (altDOWN < 0) {
406
                    var altDOWN = -altDOWN;
407
                    var prefix = "-";
408
                    var offset += 15.039;
409
                }
410
                else
411
                    var prefix = "";
412

            
413
                if (altDOWN == 0) {
414
                    var AltBigDOWN  = "";
415
                    var AltSmallDOWN    = "0";
416
                }
417
                elsif (math.mod(altDOWN,500) == 0 and altDOWN != 0) {
418
                    var AltBigDOWN  = sprintf(prefix~"%1d", altDOWN);
419
                    var AltSmallDOWN    = "";
420
                }
421
                elsif (altDOWN < 1000 and (math.mod(altDOWN,500))) {
422
                    var AltBigDOWN  = "";
423
                    var AltSmallDOWN    = sprintf(prefix~"%1d", int(math.mod(altDOWN,1000)));
424
                    var offset = -30.078;
425
                }
426
                elsif ((altDOWN < 10000) and (altDOWN >= 1000) and (math.mod(altDOWN,500))) {
427
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
428
                    var AltSmallDOWN    = sprintf("%1d", int(math.mod(altDOWN,1000)));
429
                    var offset += 15.039;
430
                }
431
                else {
432
                    var AltBigDOWN  = sprintf(prefix~"%1d", int(altDOWN/1000));
433
                    var mod = int(math.mod(altDOWN,1000));
434
                    var AltSmallDOWN    = sprintf("%1d", mod);
435
                    var offset += 30.078;
436
                }
437
                me.screenElements["AltBigD"~place].setText(AltBigDOWN);
438
                me.screenElements["AltSmallD"~place].setText(AltSmallDOWN);
439
                me.screenElements["AltSmallD"~place].setTranslation(offset,0);
440
            }
441
        }
442
        settimer(func me.updateALT(getprop('instrumentation/altimeter/indicated-altitude-ft')), 0.2);
443
    },
animation HSI
Sébastien MARQUE authored on 2017-03-11
444

            
445
    updateHSI : func (hdg) {
446
        me.screenElements.Rose
447
            .setRotation(-hdg * D2R);
448
        me.screenElements['HDG-text']
449
            .setText(sprintf("%03u°", hdg));
450
        settimer(func me.updateHSI(getprop('orientation/heading-deg')), 0.1);
451
    },
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
452

            
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
453
    updateHDG : func (hdg) {
454
        if (me.role == 'MFD')
455
            return;
456
        me.screenElements['Heading-bug']
457
            .setRotation(hdg * D2R);
458
        me.screenElements['SelectedHDG-bg']
459
            .show();
460
        me.screenElements['SelectedHDG-bgtext']
461
            .show();
462
        me.screenElements['SelectedHDG-text']
463
            .setText(sprintf('%03d°%s', hdg, ''))
464
            .show();
465
        me.addTimer(3, ['SelectedHDG-text', 'SelectedHDG-bgtext', 'SelectedHDG-bg']);
466
    },
467

            
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
468
    _updateRadio: func {
469
        # arg[0]._r = <comm|nav>
470
        if (contains(arg[0], "active")) {
471
            if (arg[0]['active'] == 'none') {
472
                me.screenElements[arg[0]._r ~ '1-selected-freq']
473
                    .setColor(1,1,1);
474
                me.screenElements[arg[0]._r ~ '2-selected-freq']
475
                    .setColor(1,1,1);
476
            }
477
            else {
478
                me.screenElements[arg[0]._r ~ arg[0]['active'] ~ '-selected-freq']
479
                    .setColor(0,1,0);
480
                me.screenElements[arg[0]._r ~ arg[0].inactive ~ '-selected-freq']
481
                    .setColor(1,1,1);
482
            }
483
        }
484
        if (contains(arg[0], 'tune')) {
485
            # n = 0 -> NAV1/COMM1
486
            # n = 1 -> NAV1/COMM2
487
            me.screenElements[arg[0]._r ~ '-freq-switch']
488
                .setTranslation(0, arg[0].tune * 25);
489
            me.screenElements[arg[0]._r ~ (arg[0].tune + 1) ~ '-standby-freq']
490
                .setColor(0,1,1);
491
            me.screenElements[arg[0]._r ~ ((arg[0].tune == 0) + 1) ~ '-standby-freq']
492
                .setColor(1,1,1);
493
        }
494
        if (contains(arg[0], 'refresh')) {
495
            # rafraichi une seule ligne NAV1/COMM1 ou NAV2/COMM2
496
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
497
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-selected-freq']
498
                .setText(sprintf(fmt, getprop('/instrumentation/'
499
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/selected-mhz')));
500
            me.screenElements[arg[0]._r ~ arg[0].refresh ~ '-standby-freq']
501
                .setText(sprintf(fmt, getprop('/instrumentation/'
502
                               ~ arg[0]._r ~ '[' ~ (arg[0].refresh - 1) ~ ']/frequencies/standby-mhz')));
503
        }
504
        if (contains(arg[0], 'set')) {
505
            # positionne la valeur modifiée, les listeners "trigguent" en permanence ces propriétés, donc exit
506
            var n = getprop('/instrumentation/zkv1000/radios/' ~ arg[0]._r ~ '-tune');
507
            var fmt = (arg[0]._r == 'nav') ? '%.2f' : '%.3f';
508
            me.screenElements[arg[0]._r ~ (n + 1) ~ '-standby-freq']
509
                .setText(getprop('/instrumentation/' ~ arg[0]._r ~ '[' ~ n ~ ']/frequencies/standby-mhz'));
510
        }
511
        if (contains(arg[0], 'auto')) {
512
            # pour rafraichir automagiquement, toutes les deux secondes un refresh pour un NAV
513
            var radio = arg[0].auto;
514
            me._updateRadio({refresh: 1, _r: radio});
515
            settimer(func me._updateRadio({refresh: 2, _r: radio}), 1);
516
            settimer(func me._updateRadio({auto: radio}), 2);
517
        }
518
    },
519

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
520
    updateNAV : func {
521
        # made active via menu
522
        if (contains(arg[0], "active")) {
523
            if (arg[0]['active'] == 'none') {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
524
                arg[0]._r = 'nav';
525
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
526
                me.screenElements['nav1-id']
527
                    .setColor(1,1,1);
528
                me.screenElements['nav2-id']
529
                    .setColor(1,1,1);
530
                me.screenElements['NAV1-pointer']
531
                    .hide();
532
                me.screenElements['NAV2-pointer']
533
                    .hide();
534
            }
535
            else {
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
536
                arg[0]._r = 'nav';
537
                arg[0].inactive = (arg[0]['active'] == 1) + 1;
538
                me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
539
                me.screenElements['nav' ~ arg[0]['active'] ~ '-id']
540
                    .setColor(0,1,0);
541
                me.screenElements['NAV' ~ arg[0]['active'] ~ '-pointer']
542
                    .show();
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
543
                me.screenElements['nav' ~ arg[0].inactive ~ '-id']
544
                    .setColor(1,1,1);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
545
#                me.screenElements['HDI']
546
#                    .setRotation();
547
#                me.screenElements['NAV' ~ inactive ~ '-pointer']
548
#                    .hide();
549
#                foreach (var e; [ 'FROM', 'TO', 'CDI' ])
550
#                    me.screenElements['NAV' ~ inactive ~ '-' ~ e]
551
#                        .hide();
552
            }
553
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
554
        elsif (contains(arg[0], 'nav-id')) {
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
555
            # TODO: récupérer la valeur via les paramètres transmis du listener
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
556
            if (arg[0].val == nil)
557
                arg[0].val = '';
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
558
            me.screenElements["nav" ~ arg[0]['nav-id'] ~ "-id"]
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
559
                    .setText(arg[0].val);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
560
        }
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
561
        else {
562
            arg[0]._r = 'nav';
563
            me._updateRadio(arg[0]);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
564
        }
565
    },
ajout COMM, et factorisation...
Sébastien MARQUE authored on 2017-03-12
566

            
567
    updateCOMM: func {
568
        arg[0]._r = 'comm';
569
        me._updateRadio(arg[0]);
570
    },
commit initial
Sébastien MARQUE authored on 2017-03-07
571
};