Merge branch 'master' of gitorious.org:fg/fgdata
[fg:toms-fgdata.git] / Aircraft / tu154b / Nasal / warn.nas
1 #
2 # NASAL systems for TU-154B
3 # Yurik V. Nikiforoff, yurik.nsk@gmail.com
4 # Novosibirsk, Russia
5 # jan 2008, 2010
6 #
7 #
8 # Warning & alarm
9 #
10
11 var UPDATE_PERIOD = 0.5;
12 # sound
13 var horn = aircraft.light.new("tu154/systems/warning/horn", [0.5, 0.2] );
14 var alarm = aircraft.light.new("tu154/systems/warning/alarm", [0.5, 0.2] );
15 # light
16 var not_ready = aircraft.light.new("tu154/systems/warning/not-ready", [0.3, 0.3] );
17 var iso = aircraft.light.new("tu154/systems/warning/iso", [0.5, 0.5] );
18 var ground = aircraft.light.new("tu154/systems/warning/ground", [0.3, 0.3] );
19 var rvrn = aircraft.light.new("tu154/systems/warning/rvrn", [0.5, 0.6] );
20 var slats = aircraft.light.new("tu154/systems/warning/slats", [0.4, 0.4] );
21 var gear = aircraft.light.new("tu154/systems/warning/gear", [0.5, 0.5] );
22 var voice_h = aircraft.light.new("tu154/systems/warning/voice", [3.5, 1.0] );
23
24 # Strobe
25 var strobe = aircraft.light.new("tu154/light/strobe", [0.1, 1.5] );
26 #var strobe_2 = aircraft.light.new("tu154/light/strobe-2", [0.1, 1.4] );
27 # blank all if we lose 27 V power
28 var blank_all = func{
29 setprop("tu154/systems/electrical/indicators/wrong-trim", 0 );
30 setprop("tu154/systems/electrical/indicators/pitch", 0 );
31 setprop("tu154/systems/warning/absu/state", 0 );
32 setprop("tu154/systems/warning/alarm/absu_warn", 0 );
33 setprop("tu154/systems/electrical/indicators/right-bank", 0 );
34 setprop("tu154/systems/electrical/indicators/left-bank", 0 );
35 setprop("tu154/systems/electrical/indicators/reject", 0 );
36 setprop("tu154/systems/electrical/indicators/heading", 0 );
37 setprop("tu154/systems/electrical/indicators/vor", 0 );
38 setprop("tu154/systems/electrical/indicators/glideslope", 0 );
39 setprop("tu154/systems/electrical/indicators/at-failure", 0 );
40 setprop("tu154/systems/electrical/indicators/autothrottle", 0 );
41 setprop("tu154/systems/electrical/indicators/wrong-approach-h", 0 );
42 setprop("tu154/systems/electrical/indicators/wrong-approach-v", 0 );
43 setprop("tu154/systems/electrical/indicators/fire", 0 );
44 setprop("tu154/systems/electrical/indicators/fuel-2500", 0 );
45 setprop("tu154/systems/electrical/indicators/speed-limit", 0 );
46 setprop("tu154/systems/electrical/indicators/acceleration", 0 );
47 setprop("tu154/systems/electrical/indicators/alpha", 0 );
48 setprop("tu154/systems/electrical/indicators/bank", 0 );
49 setprop("tu154/systems/electrical/indicators/signal-danger", 0 );
50 setprop("tu154/systems/electrical/indicators/signal-radio", 0 );
51 setprop("tu154/systems/electrical/indicators/autopilot", 0 );
52 setprop("tu154/systems/electrical/indicators/zk", 0 );
53 setprop("tu154/systems/electrical/indicators/stab-pitch", 0 );
54 setprop("tu154/systems/electrical/indicators/stab-heading", 0 );
55 setprop("tu154/systems/electrical/indicators/contr-gyro", 0 );
56 setprop("tu154/systems/electrical/indicators/stab-m", 0 );
57 setprop("tu154/systems/electrical/indicators/stab-v", 0 );
58 setprop("tu154/systems/electrical/indicators/stab-h", 0 );
59 setprop("tu154/systems/electrical/indicators/nvu", 0 );
60 setprop("tu154/systems/electrical/indicators/beacon-inner", 0 );        
61 setprop("tu154/systems/electrical/indicators/beacon-middle", 0 );
62 setprop("tu154/systems/electrical/indicators/beacon-outer", 0 );
63 setprop("tu154/systems/electrical/indicators/azimuth-avton", 0 );
64 setprop("tu154/systems/electrical/indicators/range-avton", 0 );
65 setprop("tu154/systems/electrical/indicators/change-waypoint", 0 );
66 setprop("tu154/systems/electrical/indicators/nvu-correction-on", 0 );
67 setprop("tu154/systems/electrical/indicators/nvu-failure", 0 );
68 setprop("tu154/systems/electrical/indicators/nvu-vor-avton", 0 );
69
70 setprop("tu154/instrumentation/uap-12/warn", 0 );
71 setprop("tu154/systems/electrical/indicators/memory-diss", 0 );
72 setprop("tu154/systems/electrical/indicators/rudder-trim-neutral", 0 );
73 setprop("tu154/systems/electrical/indicators/aileron-trim-neutral", 0 );
74 setprop("tu154/systems/electrical/indicators/elevator-trim-neutral", 0 );
75 setprop("tu154/systems/electrical/indicators/stab-on", 0.0);    
76 setprop("tu154/systems/warning/run-stabilizer/state", 0.0 );            
77 setprop("tu154/systems/electrical/indicators/flaps-1", 0.0 );
78 setprop("tu154/systems/electrical/indicators/flaps-2", 0.0 );
79 setprop("tu154/systems/warning/run-flaps/state", 0.0 );         
80 setprop("tu154/systems/warning/iso/state", 0.0 );
81 setprop("tu154/systems/electrical/indicators/interceptor-outer", 0.0 );
82 setprop("tu154/systems/electrical/indicators/interceptor-inner", 0.0 );
83 setprop("tu154/systems/electrical/indicators/gear-red-1", 0.0 );
84 setprop("tu154/systems/electrical/indicators/gear-red-2", 0.0 );
85 setprop("tu154/systems/electrical/indicators/gear-red-3", 0.0 );
86 setprop("tu154/systems/electrical/indicators/gear-green-1", 0.0 );
87 setprop("tu154/systems/electrical/indicators/gear-green-2", 0.0 );
88 setprop("tu154/systems/electrical/indicators/gear-green-3", 0.0 );
89 setprop("tu154/systems/electrical/indicators/engine-1/revers-lock",0.0);
90 setprop("tu154/systems/electrical/indicators/engine-3/revers-lock",0.0);
91 setprop("tu154/systems/electrical/indicators/engine-1/revers-dampers",0.0);
92 setprop("tu154/systems/electrical/indicators/engine-3/revers-dampers",0.0);
93
94 setprop("tu154/instrumentation/pn-6/lamp-1", 0.0 );
95 setprop("tu154/instrumentation/pn-6/lamp-2", 0.0 );
96 setprop("tu154/instrumentation/pn-6/lamp-3", 0.0 );
97
98
99 setprop("tu154/lamps/p-hydro-1",0.0);
100 setprop("tu154/lamps/p-hydro-2",0.0);
101 setprop("tu154/lamps/p-hydro-3",0.0);
102 setprop("tu154/lamps/p-hydro-brake",0.0);
103
104 # Light
105 setprop("tu154/light/instruments/int-blue",0.0);
106 setprop("tu154/light/instruments/int-green",0.0);
107 setprop("tu154/light/instruments/int-red",0.0);
108
109 setprop("tu154/light/panel/ext-blue",0.0);
110 setprop("tu154/light/panel/ext-green",0.0);
111 setprop("tu154/light/panel/ext-red",0.0);
112
113 setprop("tu154/light/panel/amb-blue",0.0);
114 setprop("tu154/light/panel/amb-green",0.0);
115 setprop("tu154/light/panel/amb-red",0.0);
116
117 setprop("tu154/light/nav/red", 0.0 );
118 setprop("tu154/light/nav/green", 0.0 );
119 setprop("tu154/light/nav/blue", 0.0 );
120
121 setprop("tu154/systems/warning/voice/eng-ready", 0.0);
122 setprop("tu154/systems/warning/voice/nav-ready", 0.0 );
123 setprop("tu154/systems/warning/voice/sp-ready", 0.0 );
124
125
126 # flashes
127 iso.switch(0);
128 horn.switch(0);
129 alarm.switch(0); 
130 ground.switch(0);
131 rvrn.switch(0);
132 slats.switch(0);
133 gear.switch(0);
134 not_ready.switch(0);
135 strobe.switch(0);
136 #strobe_2.switch(0);
137
138 # PKP blankers
139 setprop("tu154/instrumentation/pkp/kurs-blanker", 1 );
140 setprop("tu154/instrumentation/pkp/gliss-blanker", 1 );
141 }
142
143 var nav_lighting = func{
144 if( arg[0] ) {
145         setprop("tu154/light/nav/red", 1.0 );
146         setprop("tu154/light/nav/green", 1.0 );
147         setprop("tu154/light/nav/blue", 1.0 );
148         }
149 else {
150         setprop("tu154/light/nav/red", 0.0 );
151         setprop("tu154/light/nav/green", 0.0 );
152         setprop("tu154/light/nav/blue", 0.0 );
153         }
154
155 }
156
157 var strobe_selector = func{
158
159   var state = getprop("tu154/light/strobe/state" );
160   var selector = getprop("tu154/light/strobe/strobe_selector" );
161   if( selector ) setprop( "tu154/light/strobe/strobe_1", state );
162   else setprop( "tu154/light/strobe/strobe_2", state );
163   if( state ) return;   # listener invoked by ether variation of flag, so we divide events by 2
164 #print("Strobe!");
165   if( selector )
166         setprop("tu154/light/strobe/strobe_selector", 0.0 );
167   else
168         setprop("tu154/light/strobe/strobe_selector", 1.0 )
169 }
170
171 setlistener( "tu154/light/strobe/state", strobe_selector, 1, 0 );
172
173 var panel_lighting = func{
174 if( arg[0] ) {
175         setprop("tu154/light/instruments/int-blue",
176                 getprop("tu154/light/instruments/int-blue-def") );
177         setprop("tu154/light/instruments/int-green",
178                 getprop("tu154/light/instruments/int-green-def") );
179         setprop("tu154/light/instruments/int-red",
180                 getprop("tu154/light/instruments/int-red-def") );
181         setprop("tu154/light/panel/ext-blue",
182                 getprop("tu154/light/panel/ext-blue-def") );
183         setprop("tu154/light/panel/ext-green",
184                 getprop("tu154/light/panel/ext-green-def") );
185         setprop("tu154/light/panel/ext-red",
186                 getprop("tu154/light/panel/ext-red-def") );
187         setprop("tu154/light/panel/amb-blue",
188                 getprop("tu154/light/panel/amb-blue-def") );
189         setprop("tu154/light/panel/amb-green",
190                 getprop("tu154/light/panel/amb-green-def") );
191         setprop("tu154/light/panel/amb-red",
192                 getprop("tu154/light/panel/amb-red-def") );
193         # night VC textures
194         setprop("tu154/textures/capt-panel","vc01_night.rgb" );
195         setprop("tu154/textures/copilot-panel","vc02_night.rgb" );
196         setprop("tu154/textures/overhead-panel","vc06_l.rgb" );
197         setprop("tu154/textures/fe-panel","vc08_l.rgb" );
198         setprop("tu154/textures/tablo","tablo_1_n.rgb" );
199         setprop("tu154/textures/tablo_1","tablo_2_n.rgb" );
200         setprop("tu154/textures/tablo_2","tablo_3_n.rgb" );
201         setprop("tu154/textures/tablo_3","tablo_4_n.rgb" );
202         setprop("tu154/textures/tablo_4","tablo_5_n.rgb" );
203         setprop("tu154/textures/tablo_5","tablo_6_n.rgb" );
204         setprop("tu154/textures/tablo_6","tablo_7_n.rgb" );
205         setprop("tu154/textures/tablo_7","tablo_8_n.rgb" );
206         setprop("tu154/textures/tablo_8","tablo_9_n.rgb" );
207         setprop("tu154/textures/tablo_9","tablo_10_n.rgb" );
208         setprop("tu154/textures/tablo_10","tablo_11_n.rgb" );
209         setprop("tu154/textures/tablo_11","tablo_12_n.rgb" );
210         setprop("tu154/textures/tablo_12","tablo_13_n.rgb" );
211         setprop("tu154/textures/tablo_13","tablo_14_n.rgb" );
212         setprop("tu154/textures/tablo_14","tablo_15_n.rgb" );
213         setprop("tu154/textures/tablo_15","tablo_16_n.rgb" );
214                         
215         }
216 else {
217         setprop("tu154/light/instruments/int-blue",0.0);
218         setprop("tu154/light/instruments/int-green",0.0);
219         setprop("tu154/light/instruments/int-red",0.0);
220         
221         setprop("tu154/light/panel/ext-blue",0.0);
222         setprop("tu154/light/panel/ext-green",0.0);
223         setprop("tu154/light/panel/ext-red",0.0);
224         
225         setprop("tu154/light/panel/amb-blue",0.0);
226         setprop("tu154/light/panel/amb-green",0.0);
227         setprop("tu154/light/panel/amb-red",0.0);
228         # Daily VC textures
229         setprop("tu154/textures/capt-panel","vc01_t.rgb" );
230         setprop("tu154/textures/copilot-panel","vc02_t.rgb" );
231         setprop("tu154/textures/overhead-panel","vc06_t.rgb" );
232         setprop("tu154/textures/fe-panel","vc08_t.rgb" );
233         setprop("tu154/textures/tablo","tablo_1.rgb" );
234         setprop("tu154/textures/tablo_1","tablo_2.rgb" );
235         setprop("tu154/textures/tablo_2","tablo_3.rgb" );
236         setprop("tu154/textures/tablo_3","tablo_4.rgb" );
237         setprop("tu154/textures/tablo_4","tablo_5.rgb" );
238         setprop("tu154/textures/tablo_5","tablo_6.rgb" );
239         setprop("tu154/textures/tablo_6","tablo_7.rgb" );
240         setprop("tu154/textures/tablo_7","tablo_8.rgb" );
241         setprop("tu154/textures/tablo_8","tablo_9.rgb" );
242         setprop("tu154/textures/tablo_9","tablo_10.rgb" );
243         setprop("tu154/textures/tablo_10","tablo_11.rgb" );
244         setprop("tu154/textures/tablo_11","tablo_12.rgb" );
245         setprop("tu154/textures/tablo_12","tablo_13.rgb" );
246         setprop("tu154/textures/tablo_13","tablo_14.rgb" );
247         setprop("tu154/textures/tablo_14","tablo_15.rgb" );
248         setprop("tu154/textures/tablo_15","tablo_16.rgb" );
249         }
250
251 }
252
253 var horn_handler = func{
254 settimer( horn_handler, UPDATE_PERIOD );
255 var pwr = getprop("tu154/systems/electrical/buses/DC27-bus-L/volts");
256 if( pwr == nil ) return;
257 if(  pwr < 13.0 )
258         { #27 V absent
259         horn.switch(0); 
260         setprop("tu154/systems/warning/horn/const", 0 );
261         return;
262         }
263 var horn_pulse_src = 0.0;
264 var horn_const_src = 0.0;
265
266 # On-ground
267
268 if( getprop( "controls/engines/engine/throttle" ) > 0.85 )
269         if( getprop( "fdm/jsbsim/fcs/flap-pos-deg" ) < 14.0 )
270                 if( getprop( "gear/gear[1]/wow" ) == 1 )
271                         horn_const_src = horn_const_src + 1.0;
272
273
274 # added by Yurik sep 2012
275 #
276 # Modified horn warning system
277 #
278 if( getprop( "gear/gear[1]/wow" ) == 0 )                        # in air
279   if( getprop( "controls/engines/engine/throttle" ) < 0.15 )    # Idle engines
280   {
281                                                                 # Forbidden pair:
282
283   if( getprop( "fdm/jsbsim/gear/gear-pos-norm" ) != 1.0 )       # Gear retracted
284       if( getprop( "fdm/jsbsim/fcs/flap-pos-deg" ) > 3.0 )      # Flaps extended
285                 horn_const_src = horn_const_src + 1.0;
286
287   if( getprop( "fdm/jsbsim/gear/gear-pos-norm" ) == 1.0 )       # Gear extended
288       if( getprop( "fdm/jsbsim/fcs/flap-pos-deg" ) < 3.0 )      # Flaps retracted
289                 horn_const_src = horn_const_src + 1.0;
290
291   }
292
293 # set output
294 if( horn_const_src > 0.0 ) 
295         setprop("tu154/systems/warning/horn/const", 1 );
296 else    
297         setprop("tu154/systems/warning/horn/const", 0 );
298
299 }
300
301 var audio_handler = func{
302 settimer( audio_handler, UPDATE_PERIOD );
303 var pwr = getprop("tu154/systems/electrical/buses/DC27-bus-L/volts");
304 if( pwr == nil ) return;
305 if(  pwr < 13.0 )
306         { #27 V absent
307         alarm.switch(0); 
308         setprop("tu154/systems/warning/alarm/const", 0 );
309         return;
310         }
311 var alarm_pulse_src = 0.0;
312 var alarm_const_src = 0.0;
313
314 # AUASP
315 if( getprop( "tu154/instrumentation/uap-12/warn" ) == 1.0 )
316                 alarm_const_src = alarm_const_src + 1.0;
317
318 # ABSU
319 if( getprop( "tu154/systems/warning/absu" ) == 1.0 )
320                 alarm_pulse_src = alarm_pulse_src + 1.0;
321 # Speed
322 if( getprop( "tu154/systems/electrical/indicators/speed-limit" ) > 0.0 )
323                 alarm_pulse_src = alarm_pulse_src + 1.0;
324
325 # Fuel
326 if( getprop( "tu154/systems/electrical/indicators/fuel-2500" ) > 0.0 )
327                 alarm_pulse_src = alarm_pulse_src + 1.0;
328 # Checking lamps
329 if( getprop( "tu154/systems/electrical/checking-lamps/main-panel" ) > 0.0 )
330                 alarm_pulse_src = 0.0;
331 # set output
332 if( alarm_const_src > 0.0 ) setprop("tu154/systems/warning/alarm/const", 1 );
333 else setprop("tu154/systems/warning/alarm/const", 0 );
334
335 if( alarm_pulse_src > 0.0 ) alarm.switch(1);
336 else alarm.switch(0);
337
338 }
339
340 var RV_OFFSET = 3.5;
341 var voice_handler = func{
342 settimer( voice_handler, 0.0 ); # no need delay for voise
343 if( getprop("tu154/instrumentation/rv-5m/serviceable") != 1 ) return; #power off
344 var alt = getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" );
345 if( alt == nil ) alt = 0.0;
346 # flash control
347 if( alt < (0.5 + RV_OFFSET) )
348         voice_h.switch(0);
349 if( alt > (10.5 + RV_OFFSET) )
350         voice_h.switch(0);
351
352 # We count altitude for landing only...
353 if( getprop( "velocities/speed-down-fps" ) < 0.0 ) { voice_h.switch(0); return; }
354 # ...and for fly
355 if( getprop( "gear/gear[0]/wow" ) == 1.0 ) { voice_h.switch(0); return; }
356 if( getprop( "gear/gear[1]/wow" ) == 1.0 ) { voice_h.switch(0); return; }
357 if( getprop( "gear/gear[2]/wow" ) == 1.0 ) { voice_h.switch(0); return; }
358         
359 if( alt > RV_OFFSET ){
360         if( alt < (1.3 + RV_OFFSET) )
361                 {
362                 setprop( "tu154/systems/warning/voice/altitude", 1.0 );
363                 voice_h.switch(1);
364 }}
365 if( alt < (3.0 + RV_OFFSET) ){
366         if( alt > (2.5 + RV_OFFSET) )
367                 {
368                 setprop( "tu154/systems/warning/voice/altitude", 3.0 );
369                 voice_h.switch(1);
370 }}
371 if( alt < (6.0 + RV_OFFSET) ){
372         if( alt > (3.5 + RV_OFFSET) )
373                 {
374                 setprop( "tu154/systems/warning/voice/altitude", 6.0 );
375                 voice_h.switch(1);
376 }}
377 if( alt < (10.0 + RV_OFFSET) ){
378         if( alt > (6.5 + RV_OFFSET) )
379                 {
380                 setprop( "tu154/systems/warning/voice/altitude", 10.0 );
381                 voice_h.switch(1);
382 }}
383 # Non-repeatable count          
384 if( alt < (20.0 + RV_OFFSET) )
385         if( alt > (11.0 + RV_OFFSET) )
386                 setprop( "tu154/systems/warning/voice/altitude", 20.0 );
387 if( alt < (30.0 + RV_OFFSET) )
388         if( alt > (25.0 + RV_OFFSET) )
389                 setprop( "tu154/systems/warning/voice/altitude", 30.0 );
390 if( alt < (40.0 + RV_OFFSET) )
391         if( alt > (38.0 + RV_OFFSET) )
392                 setprop( "tu154/systems/warning/voice/altitude", 40.0 );
393 if( alt < (55.0 + RV_OFFSET) )
394         if( alt > (53.0 + RV_OFFSET) )
395                 setprop( "tu154/systems/warning/voice/altitude", 55.0 );                
396 if( alt < (60.0 + RV_OFFSET) )
397         if( alt > (58.0 + RV_OFFSET) )
398                 setprop( "tu154/systems/warning/voice/altitude", 60.0 );
399 if( alt < (80.0 + RV_OFFSET) )
400         if( alt > (78.0 + RV_OFFSET) )
401                 setprop( "tu154/systems/warning/voice/altitude", 80.0 );
402 if( alt < (90.0 + RV_OFFSET) )
403         if( alt > (88.0 + RV_OFFSET) )
404                 setprop( "tu154/systems/warning/voice/altitude", 90.0 );                
405 if( alt < (100.0 + RV_OFFSET) )
406         if( alt > (98.0 + RV_OFFSET) )
407                 setprop( "tu154/systems/warning/voice/altitude", 100.0 );
408 if( alt < (120.0 + RV_OFFSET) )
409         if( alt > (118.0 + RV_OFFSET) )
410                 setprop( "tu154/systems/warning/voice/altitude", 120.0 );
411 if( alt < (150.0 + RV_OFFSET) )
412         if( alt > (148.0 + RV_OFFSET) )
413                 setprop( "tu154/systems/warning/voice/altitude", 150.0 );
414 if( alt < (200.0 + RV_OFFSET) )
415         if( alt > (208.0 + RV_OFFSET) )
416                 setprop( "tu154/systems/warning/voice/altitude", 200.0 );
417 if( alt < (250.0 + RV_OFFSET) )
418         if( alt > (248.0 + RV_OFFSET) )
419                 setprop( "tu154/systems/warning/voice/altitude", 250.0 );
420
421 }
422
423 var check_lamps_capt = func{
424         var pwr = getprop("tu154/systems/electrical/buses/DC27-bus-L/volts");
425         if( pwr == nil ) return;
426         if(  pwr < 13.0 )
427         { #27 V absent
428         blank_all();
429         return;
430         }
431         var param = getprop( "tu154/systems/electrical/checking-lamps/main-panel" );
432         if( param == nil ) param = 0.0;
433         setprop("tu154/systems/electrical/indicators/wrong-trim", param );
434         setprop("tu154/systems/electrical/indicators/pitch", param );
435         setprop("tu154/systems/electrical/indicators/heading", param );
436         setprop("tu154/systems/electrical/indicators/bank", param );
437         setprop("tu154/systems/electrical/indicators/right-bank", param );
438         setprop("tu154/systems/electrical/indicators/left-bank", param );
439         setprop("tu154/systems/electrical/indicators/reject", param );
440         setprop("tu154/systems/electrical/indicators/vor", param );
441         setprop("tu154/systems/electrical/indicators/glideslope", param );
442         setprop("tu154/systems/electrical/indicators/at-failure", param );
443         setprop("tu154/systems/electrical/indicators/autothrottle", param );
444         setprop("tu154/systems/electrical/indicators/wrong-approach-h", param );
445         setprop("tu154/systems/electrical/indicators/wrong-approach-v", param );
446         setprop("tu154/systems/electrical/indicators/fire", param );
447         setprop("tu154/systems/electrical/indicators/fuel-2500", param );
448         setprop("tu154/systems/electrical/indicators/speed-limit", param );
449         setprop("tu154/systems/electrical/indicators/acceleration", param );
450         setprop("tu154/systems/electrical/indicators/alpha", param );
451         setprop("tu154/systems/electrical/indicators/signal-danger", param );
452         setprop("tu154/systems/electrical/indicators/signal-radio", param );
453         setprop("tu154/systems/electrical/indicators/autopilot", param );
454         setprop("tu154/systems/electrical/indicators/contr-gyro", param );
455         setprop("tu154/systems/electrical/indicators/zk", param );
456         setprop("tu154/systems/electrical/indicators/stab-pitch", param );
457         setprop("tu154/systems/electrical/indicators/stab-heading", param );
458         setprop("tu154/systems/electrical/indicators/stab-m", param );
459         setprop("tu154/systems/electrical/indicators/stab-v", param );
460         setprop("tu154/systems/electrical/indicators/stab-h", param );
461         setprop("tu154/systems/electrical/indicators/nvu", param );
462         setprop("tu154/systems/electrical/indicators/beacon-inner", param );    
463         setprop("tu154/systems/electrical/indicators/beacon-middle", param );
464         setprop("tu154/systems/electrical/indicators/beacon-outer", param );
465 #setprop("tu154/systems/electrical/indicators/change-waypoint", param );
466         setprop("tu154/systems/electrical/indicators/nvu-correction-on", param );
467         setprop("tu154/systems/electrical/indicators/nvu-failure", param );
468         setprop("tu154/systems/electrical/indicators/nvu-vor-avton", param );
469         
470         setprop("tu154/systems/electrical/indicators/memory-diss", param );
471         setprop("tu154/systems/electrical/indicators/rudder-trim-neutral", param );
472         setprop("tu154/systems/electrical/indicators/aileron-trim-neutral", param );
473         setprop("tu154/systems/electrical/indicators/elevator-trim-neutral", param );
474         setprop("tu154/systems/electrical/indicators/stab-on", param);  
475         setprop("tu154/systems/electrical/indicators/flaps-1", param );
476         setprop("tu154/systems/electrical/indicators/flaps-2", param );
477         setprop("tu154/systems/electrical/indicators/interceptor-outer", param );
478         setprop("tu154/systems/electrical/indicators/interceptor-inner", param );
479         setprop("tu154/systems/electrical/indicators/gear-red-1", param );
480         setprop("tu154/systems/electrical/indicators/gear-red-2", param );
481         setprop("tu154/systems/electrical/indicators/gear-red-3", param );
482         setprop("tu154/systems/electrical/indicators/gear-green-1", param );
483         setprop("tu154/systems/electrical/indicators/gear-green-2", param );
484         setprop("tu154/systems/electrical/indicators/gear-green-3", param );
485         setprop("tu154/systems/electrical/indicators/azimuth-avton", param );
486         setprop("tu154/systems/electrical/indicators/range-avton", param );
487         
488         setprop("tu154/systems/warning/run-stabilizer/state", param );          
489         setprop("tu154/systems/warning/run-flaps/state", param );
490         setprop("tu154/systems/warning/iso/state", param );
491         setprop("tu154/systems/warning/not_ready/state", param );
492         setprop("tu154/systems/warning/ground/state", param );
493
494         setprop("tu154/instrumentation/pn-6/lamp-1", param );
495         setprop("tu154/instrumentation/pn-6/lamp-2", param );
496         setprop("tu154/instrumentation/pn-6/lamp-3", param );
497         setprop("tu154/instrumentation/pn-6/lamp-4", param );
498         setprop("tu154/instrumentation/pn-6/lamp-5", param );
499         setprop("tu154/instrumentation/pn-6/g1", param );
500         setprop("tu154/instrumentation/pn-6/g2", param );
501         setprop("tu154/instrumentation/pn-6/g3", param );
502
503
504 }
505
506 var indicator_handler = func{
507 settimer( indicator_handler, UPDATE_PERIOD );
508 var pwr = getprop("tu154/systems/electrical/buses/DC27-bus-L/volts");
509 if( pwr == nil ) return;
510 if(  pwr < 13.0 )
511         { #27 V absent
512         blank_all();
513         not_ready.switch(0);
514         return;
515         }
516 # Check lamps on captain panel
517 if( getprop( "tu154/systems/electrical/checking-lamps/main-panel" ) == 1.0 ) return;
518
519 var param = 0.0;
520
521 # "Podg navigacii" switch control 
522 if( getprop("tu154/switches/pn-5-posadk") ) param = param + 1;
523 if( !getprop("tu154/switches/pn-5-navigac") ) param = param + 1;
524 if( param == 2 ){
525         setprop("tu154/instrumentation/pn-6/lamp-1", 1.0 );
526         setprop("tu154/instrumentation/pn-6/lamp-2", 1.0 );
527         setprop("tu154/instrumentation/pn-6/lamp-3", 1.0 );
528         }
529 else {
530         setprop("tu154/instrumentation/pn-6/lamp-1", 0.0 );
531         setprop("tu154/instrumentation/pn-6/lamp-2", 0.0 );
532         setprop("tu154/instrumentation/pn-6/lamp-3", 0.0 );
533 }
534
535 # not ready to takeoff
536 param = 0.0;
537 if( getprop( "tu154/switches/busters-cover" ) != 0.0 ) param = param + 1.0;
538 if( getprop( "tu154/switches/steering" ) == 0.0 ) param = param + 1.0;
539 if( getprop( "tu154/switches/steering-limit" ) == 0.0 ) param = param + 1.0;
540 #if( getprop( "tu154/switches/steering-cover" ) == 1.0 ) param = param + 1.0;
541 #if( getprop( "tu154/switches/steering-limit-cover" ) == 1.0 ) param = param + 1.0;
542 if( getprop( "fdm/jsbsim/fcs/flap-pos-deg" ) < 14.0 ) param = param + 1.0;
543 if( getprop( "gear/gear[1]/wow" ) == 0 ) param = 0.0;# we are in fly
544
545 if( param > 0.0 ) { not_ready.switch(1); }
546 else { if( getprop( "tu154/systems/warning/not-ready/enabled" ) != 0 )
547         {
548         not_ready.switch(0);
549         if( getprop( "fdm/jsbsim/velocities/vc-kts" ) < 60.0 )
550 { # time for speech - only if we stay. If we run - keep silence.
551         interpolate("tu154/systems/warning/voice/eng-ready", 1.0, 2.0 );
552         interpolate("tu154/systems/warning/voice/nav-ready", 1.0, 3.0 );
553         interpolate("tu154/systems/warning/voice/sp-ready", 1.0, 4.0 );
554         }}
555      }
556
557 # wrong trim
558 param = 0.0;
559 if( getprop( "tu154/systems/warning/elevator-trim-pressed" ) == 1.0 ) 
560         if( getprop( "fdm/jsbsim/ap/pitch-hold" ) == 1.0 ) 
561                 param = param + 1.0;
562
563 setprop("tu154/systems/warning/elevator-trim-pressed", 0.0 );
564
565 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/wrong-trim", 1 );
566 else setprop("tu154/systems/electrical/indicators/wrong-trim", 0 );
567
568 # ABSU roll hydrosystem failure
569 param = 0.0;
570 if( getprop( "tu154/systems/absu/roll_ok" ) == 0.0 ) 
571         if( getprop( "fdm/jsbsim/ap/roll-hold" ) == 1.0 ) 
572                 param = param + 1.0;
573                 
574 # KURS-MP failure approach
575 if( getprop( "fdm/jsbsim/ap/roll-hold" ) == 1.0 ) 
576    if( getprop( "fdm/jsbsim/ap/roll-selector" ) == 5.0 ) 
577         if( getprop("instrumentation/nav[0]/data-is-valid" ) != 1 )
578                 param = param + 1.0;
579                 
580 if( getprop( "fdm/jsbsim/ap/roll-hold" ) == 1.0 ) 
581    if( getprop( "fdm/jsbsim/ap/roll-selector" ) == 5.0 ) 
582         if( getprop("instrumentation/nav[0]/nav-loc" ) != 1 )
583                 param = param + 1.0;
584                 
585 if( getprop( "fdm/jsbsim/ap/roll-hold" ) == 1.0 ) 
586    if( getprop( "fdm/jsbsim/ap/roll-selector" ) == 5.0 ) 
587         if( getprop("instrumentation/nav[0]/in-range" ) != 1 )
588                 param = param + 1.0;
589 # TKS failure approach
590 if( getprop( "fdm/jsbsim/ap/roll-hold" ) == 1.0 ) 
591    if( getprop( "fdm/jsbsim/ap/roll-selector" ) == 5.0 ) 
592         if( getprop("instrumentation/heading-indicator[0]/serviceable" ) != 1 )
593                 if( getprop("instrumentation/heading-indicator[1]/serviceable" ) != 1 )
594                 param = param + 1.0;
595
596 # KURS-MP failure VOR
597
598 # if( getprop( "tu154/systems/electrical/indicators/vor" ) == 1.0 ) 
599 #       if( getprop("instrumentation/nav[0]/data-is-valid" ) != 1 )
600 #               param = param + 1.0;
601 # if( getprop( "tu154/systems/electrical/indicators/vor" ) == 1.0 ) 
602 #       if( getprop("instrumentation/nav[0]/in-range" ) != 1 )
603 #               param = param + 1.0;
604  if( param > 0.0 ) {
605          setprop("tu154/systems/electrical/indicators/pitch", 1 );
606          setprop("tu154/systems/warning/absu", 1 );
607  }
608  else  { setprop("tu154/systems/electrical/indicators/pitch", 0 );
609          setprop("tu154/systems/warning/absu", 0 );
610  }
611                 
612  if( param > 0.0 ) {
613          setprop("tu154/systems/electrical/indicators/bank", 1 );
614          setprop("tu154/systems/warning/absu", 1 );
615          setprop("tu154/systems/electrical/indicators/heading", 0 );
616          setprop("tu154/systems/electrical/indicators/vor", 0 );
617          setprop("tu154/instrumentation/pkp/kurs-blanker", 1 );
618  }
619  else  { setprop("tu154/systems/electrical/indicators/bank", 0 );
620          setprop("tu154/systems/warning/absu", 0 );
621  }
622         
623         
624         
625 # ABSU pitch hydrosystem failure
626 param = 0.0;
627 if( getprop( "tu154/systems/absu/pitch_ok" ) == 0.0 ) 
628         if( getprop( "fdm/jsbsim/ap/pitch-hold" ) == 1.0 ) 
629                 param = param + 1.0;
630
631 # KURS-MP failure glideslope
632 if( getprop( "fdm/jsbsim/ap/pitch-hold" ) == 1.0 ) 
633    if( getprop( "fdm/jsbsim/ap/pitch-selector" ) == 5.0 ) 
634         if( getprop("instrumentation/nav[0]/data-is-valid" ) != 1 )
635                 param = param + 1.0;
636                 
637 if( getprop( "fdm/jsbsim/ap/pitch-hold" ) == 1.0 ) 
638    if( getprop( "fdm/jsbsim/ap/pitch-selector" ) == 5.0 ) 
639         if( getprop("instrumentation/nav[0]/has-gs" ) != 1 )
640                 param = param + 1.0;
641                 
642 if( getprop( "fdm/jsbsim/ap/pitch-hold" ) == 1.0 ) 
643    if( getprop( "fdm/jsbsim/ap/pitch-selector" ) == 5.0 ) 
644         if( getprop("instrumentation/nav[0]/in-range" ) != 1 )
645                 param = param + 1.0;
646                 
647 if( param > 0.0 ) {
648         setprop("tu154/systems/electrical/indicators/pitch", 1 );
649         setprop("tu154/systems/warning/absu", 1 );
650         setprop("tu154/systems/electrical/indicators/glideslope", 0 );
651         setprop("tu154/instrumentation/pkp/gliss-blanker", 1 );
652 }
653 else  { setprop("tu154/systems/electrical/indicators/pitch", 0 );
654         setprop("tu154/systems/warning/absu", 0 );
655 }
656 # ISO
657 param = 0.0;
658 if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 60.0 )
659      if( getprop( "tu154/systems/electrical/indicators/pitch" ) != 0 )
660                 param = param + 1.0;
661 if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 60.0 )
662      if( getprop( "tu154/systems/electrical/indicators/bank" ) != 0 )
663                 param = param + 1.0;
664 if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 60.0 )
665      if( getprop( "tu154/systems/electrical/indicators/wrong-approach-h" ) != 0 )
666                 param = param + 1.0;
667 if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 60.0 )
668      if( getprop( "tu154/systems/electrical/indicators/wrong-approach-v" ) != 0 )
669                 param = param + 1.0;
670
671 if( param > 0.0 ) iso.switch(1);
672 else iso.switch(0);
673
674 # AT
675 param = 0.0;
676 if( absu.absu_powered() == 1 )
677         if( getprop( "tu154/instrumentation/pn-6/serviceable" ) == 0 )
678                 param = param + 1.0;
679                 
680 if( param > 0.0 ) {
681         setprop("tu154/systems/electrical/indicators/at-failure", 1 );
682         setprop("tu154/systems/warning/absu", 1 );
683         setprop("tu154/systems/electrical/indicators/autothrottle", 0 );
684         }
685 else  { setprop("tu154/systems/electrical/indicators/at-failure", 0 );
686         setprop("tu154/systems/warning/absu", 0 );
687         }
688
689 # Wrong approach
690 param = 0.0;
691 if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 100.0 )
692      if( getprop( "tu154/instrumentation/rv-5m/warn" ) == 0 )
693         if( abs( getprop( "fdm/jsbsim/ap/heading-needle-deflection" )) > 0.2 )
694                 param = param + 1.0;
695                 
696 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/wrong-approach-h", 1 );
697 else setprop("tu154/systems/electrical/indicators/wrong-approach-h", 0 );
698
699 param = 0.0;
700 if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 100.0 )
701      if( getprop( "tu154/instrumentation/rv-5m/warn" ) == 0 )
702         if( abs( getprop( "instrumentation/nav[0]/gs-needle-deflection" )) > 0.3 )
703                 param = param + 1.0;
704                 
705 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/wrong-approach-v", 1 );
706 else setprop("tu154/systems/electrical/indicators/wrong-approach-v", 0 );
707
708 # Fire warning
709 # not implemented yet
710
711 if( getprop( "tu154/systems/warning/fire/fire" ) == 1 ) 
712         setprop("tu154/systems/electrical/indicators/fire", 1 );
713 else setprop("tu154/systems/electrical/indicators/fire", 0 );
714
715 # Low fuel
716 param = getprop( "consumables/fuel/tank[0]/level-gal_us" );
717 if ( param == nil ) param = 0.0;
718 if(  param < 826 ) # 2500 kg 0.8 kg/l 3.78 l/gal
719         setprop("tu154/systems/electrical/indicators/fuel-2500", 1 );
720 else setprop("tu154/systems/electrical/indicators/fuel-2500", 0 );
721
722 # Ground
723 param = 0.0;
724
725 if( getprop( "velocities/speed-down-fps" ) > 5.25 )
726     if( getprop( "fdm/jsbsim/gear/gear-pos-norm" ) == 0.0 )
727         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 250 )
728                 param = param + 1.0;
729
730 if( getprop( "velocities/speed-down-fps" ) > 22.9 )
731         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 50 )
732                 param = param + 1.0;
733 if( getprop( "velocities/speed-down-fps" ) > 25.6 )
734         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 100 )
735                 param = param + 1.0;
736 if( getprop( "velocities/speed-down-fps" ) > 28.0 )
737         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 150 )
738                 param = param + 1.0;
739 if( getprop( "velocities/speed-down-fps" ) > 30.3 )
740         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 200 )
741                 param = param + 1.0;
742 if( getprop( "velocities/speed-down-fps" ) > 35.0 )
743         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 300 )
744                 param = param + 1.0;
745 if( getprop( "velocities/speed-down-fps" ) > 39.4 )
746         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 400 )
747                 param = param + 1.0;
748 if( getprop( "velocities/speed-down-fps" ) > 45.0 )
749         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 500 )
750                 param = param + 1.0;
751 if( getprop( "velocities/speed-down-fps" ) > 50.0 )
752         if( getprop( "fdm/jsbsim/instrumentation/indicated-altitude-m" ) < 600 )
753                 param = param + 1.0;
754                 
755 if( param > 0.0 ){ horn.switch(1); ground.switch(1); }
756 else { horn.switch(0); ground.switch(0); }
757
758 # Speed limit
759 param = 0.0;
760 if( getprop( "fdm/jsbsim/position/h-sl-ft" ) < 22965.9 )
761         if( getprop( "fdm/jsbsim/velocities/vc-kts" ) > 324.0 )
762                 param = param + 1.0;
763 if( getprop( "fdm/jsbsim/position/h-sl-ft" ) > 22965.9 )
764         if( getprop( "fdm/jsbsim/position/h-sl-ft" ) < 33792.7 )
765                 if( getprop( "fdm/jsbsim/velocities/vc-kts" ) > 310.5 )
766                 param = param + 1.0;
767 if( getprop( "fdm/jsbsim/position/h-sl-ft" ) > 33792.7 )
768                 if( getprop( "fdm/jsbsim/velocities/mach" ) > 0.88 )
769                 param = param + 1.0;
770
771 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/speed-limit", 1 );
772 else setprop("tu154/systems/electrical/indicators/speed-limit", 0 );
773
774 # AUASP
775
776 if(  getprop( "tu154/instrumentation/uap-12/powered" ) > 0.0 )
777  {
778  # alpha
779  param = 0.0;
780  if((( getprop( "fdm/jsbsim/aero/function/auasp" ) - getprop( "fdm/jsbsim/aero/alpha-wing-rad" ) * 57.2958 ) < 0.5 ) and ( getprop( "fdm/jsbsim/velocities/vc-kts" ) > 50.0 ) )
781
782         {
783                 setprop("tu154/systems/electrical/indicators/alpha", 1 );
784                 param = param + 1.0;
785         }
786         else { setprop("tu154/systems/electrical/indicators/alpha", 0 ); }
787
788  if( getprop( "fdm/jsbsim/instrumentation/n-norm" ) < -2.3 )
789         {
790                 setprop("tu154/systems/electrical/indicators/acceleration", 1 );
791                 param = param + 1.0;
792         }
793         else { setprop("tu154/systems/electrical/indicators/acceleration", 0 ); }
794                 
795  if( param > 0.0 ) setprop("tu154/instrumentation/uap-12/warn", 1 );
796  else setprop("tu154/instrumentation/uap-12/warn", 0 );
797
798  }
799
800 # DISS
801
802 if( getprop("tu154/instrumentation/diss/serviceable") == 0.0 )
803                 setprop("tu154/systems/electrical/indicators/memory-diss", 1 );
804 else setprop("tu154/systems/electrical/indicators/memory-diss", 0 );
805
806 # Loaders RV-RN
807 param = getprop("tu154/systems/warning/rvrn/timeout");
808 if( param == nil ) param = 0.0;
809 if( param > 0.1 ) { rvrn.switch(1); }
810 else { rvrn.switch(0);
811         if( getprop("fdm/jsbsim/fcs/flap-cmd-norm" ) > 0.1 )
812         setprop("tu154/systems/warning/rvrn/state", 1.0 );
813         else setprop("tu154/systems/warning/rvrn/state", 0.0 );
814         }
815
816 # Rudder trim
817 if( abs( getprop("controls/flight/rudder-trim") ) < 0.004 )
818                 setprop("tu154/systems/electrical/indicators/rudder-trim-neutral", 1 );
819 else setprop("tu154/systems/electrical/indicators/rudder-trim-neutral", 0 );
820
821 # Aileron trim
822 if( abs( getprop("controls/flight/aileron-trim") ) < 0.004 )
823                 setprop("tu154/systems/electrical/indicators/aileron-trim-neutral", 1 );
824 else setprop("tu154/systems/electrical/indicators/aileron-trim-neutral", 0 );
825
826 # Elevator trim
827 if( abs( getprop("controls/flight/elevator-trim") ) < 0.004 )
828                 setprop("tu154/systems/electrical/indicators/elevator-trim-neutral", 1 );
829 else setprop("tu154/systems/electrical/indicators/elevator-trim-neutral", 0 );
830
831 # stabilizer indicator
832 if( getprop("tu154/systems/warning/run-stabilizer") == 1.0 )
833         setprop("tu154/systems/electrical/indicators/stab-on", 1.0 );
834 else setprop("tu154/systems/electrical/indicators/stab-on", 0.0);       
835 setprop("tu154/systems/warning/run-stabilizer", 0.0 );          
836
837 # Flaps indicator
838 if( getprop("tu154/systems/warning/run-flaps") == 1.0 )
839         {
840         setprop("tu154/systems/electrical/indicators/flaps-1", 1.0 );
841         setprop("tu154/systems/electrical/indicators/flaps-2", 1.0 );
842         }
843 else    {
844         setprop("tu154/systems/electrical/indicators/flaps-1", 0.0 );
845         setprop("tu154/systems/electrical/indicators/flaps-2", 0.0 );
846         }
847 setprop("tu154/systems/warning/run-flaps", 0.0 );               
848
849 # Slats indicator
850 param = 0.0;
851 if( getprop("fdm/jsbsim/fcs/flap-pos-deg" ) > 0.1 )
852         if( getprop("fdm/jsbsim/fcs/flap-pos-deg" ) < 14.0 )
853                 param = 1.0;
854                 
855 if( param > 0.0 ) slats.switch(1);
856 else {
857         slats.switch(0);
858         if( getprop("fdm/jsbsim/fcs/flap-pos-deg" ) > 0.1 )
859                 setprop("tu154/systems/warning/slats/state", 1.0 );
860         else setprop("tu154/systems/warning/slats/state", 0.0 );
861         }
862
863 # Speedbrake middle indicators  
864 if( getprop("surface-positions/speedbrake-pos-norm") > 0.0 )
865         setprop("tu154/systems/electrical/indicators/interceptor-outer", 1.0 );
866 else    
867         setprop("tu154/systems/electrical/indicators/interceptor-outer", 0.0 );
868 if( getprop("surface-positions/speedbrake-pos-norm") > 0.4 )
869         setprop("tu154/systems/electrical/indicators/interceptor-inner", 1.0 );
870 else    
871         setprop("tu154/systems/electrical/indicators/interceptor-inner", 0.0 );
872         
873 # Gear indicator
874 # Nose
875 param = 0.0;
876 if( getprop("gear/gear[0]/position-norm") > 0.0 )
877         if( getprop("gear/gear[0]/position-norm") < 1.0 )
878                 param = 1.0;
879 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/gear-red-2", 1.0 );
880 else    setprop("tu154/systems/electrical/indicators/gear-red-2", 0.0 );
881
882 if( getprop("gear/gear[0]/position-norm") == 1.0 )
883         setprop("tu154/systems/electrical/indicators/gear-green-2", 1.0 );
884 else    
885         setprop("tu154/systems/electrical/indicators/gear-green-2", 0.0 );
886 # Left
887 param = 0.0;
888 if( getprop("gear/gear[1]/position-norm") > 0.0 )
889         if( getprop("gear/gear[1]/position-norm") < 1.0 )
890                 param = 1.0;
891 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/gear-red-1", 1.0 );
892 else    setprop("tu154/systems/electrical/indicators/gear-red-1", 0.0 );
893
894 if( getprop("gear/gear[1]/position-norm") == 1.0 )
895         setprop("tu154/systems/electrical/indicators/gear-green-1", 1.0 );
896 else    
897         setprop("tu154/systems/electrical/indicators/gear-green-1", 0.0 );
898 # Right
899 param = 0.0;
900 if( getprop("gear/gear[2]/position-norm") > 0.0 )
901         if( getprop("gear/gear[2]/position-norm") < 1.0 )
902                 param = 1.0;
903 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/gear-red-3", 1.0 );
904 else    setprop("tu154/systems/electrical/indicators/gear-red-3", 0.0 );
905
906 if( getprop("gear/gear[2]/position-norm") == 1.0 )
907         setprop("tu154/systems/electrical/indicators/gear-green-3", 1.0 );
908 else    
909         setprop("tu154/systems/electrical/indicators/gear-green-3", 0.0 );
910 # Retract Gear indicator
911 param = 0.0;
912 if( getprop( "fdm/jsbsim/gear/gear-pos-norm" ) != 1.0 )
913         if( getprop( "controls/engines/engine/throttle" ) < 0.97 )
914                 if( getprop( "fdm/jsbsim/velocities/vc-kts" ) < 175.5 )
915                 param = param + 1.0;
916
917 if( param == 0.0 )
918 if( getprop( "tu154/systems/warning/deploy-flaps" ) > 0.1 )
919         if( getprop( "fdm/jsbsim/gear/gear-pos-norm" ) < 0.9 )
920                         param = 1.0;
921                 
922 if( param > 0.0 ) gear.switch(1);
923 else    gear.switch(0);
924
925 # gear alarm trigger reset
926 if( getprop( "fdm/jsbsim/fcs/flap-cmd-norm" ) == 0.0 )
927         setprop( "tu154/systems/warning/deploy-flaps", 0.0 );
928 if( getprop( "fdm/jsbsim/gear/gear-pos-norm" ) != 0.0 )
929         setprop( "tu154/systems/warning/deploy-flaps", 0.0 );
930
931 # Marker beacon
932 if( getprop( "instrumentation/marker-beacon[0]/serviceable" ) ) {
933 setprop("tu154/systems/electrical/indicators/beacon-inner", 
934                 getprop( "instrumentation/marker-beacon[0]/inner" ));
935 setprop("tu154/systems/electrical/indicators/beacon-middle", 
936                 getprop( "instrumentation/marker-beacon[0]/middle" ));
937 setprop("tu154/systems/electrical/indicators/beacon-outer", 
938                 getprop( "instrumentation/marker-beacon[0]/outer" ));
939 }
940  else {
941 setprop("tu154/systems/electrical/indicators/beacon-inner", 0 );
942 setprop("tu154/systems/electrical/indicators/beacon-middle", 0 );
943 setprop("tu154/systems/electrical/indicators/beacon-outer", 0 );
944 }
945         
946 # Reverser signals
947 param = 0.0;
948 if( getprop( "fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad" ) > 0.0 )
949         if( getprop( "fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad" ) < 2.3 )
950                 param = 1.0;
951 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/engine-1/revers-lock",1.0);
952 else setprop("tu154/systems/electrical/indicators/engine-1/revers-lock",0.0);
953 param = 0.0;
954 if( getprop( "fdm/jsbsim/propulsion/engine[2]/reverser-angle-rad" ) > 0.0 )
955         if( getprop( "fdm/jsbsim/propulsion/engine[2]/reverser-angle-rad" ) < 2.3 )
956                 param = 1.0;
957 if( param > 0.0 ) setprop("tu154/systems/electrical/indicators/engine-3/revers-lock",1.0);
958 else setprop("tu154/systems/electrical/indicators/engine-3/revers-lock",0.0);
959
960 if( getprop( "fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad" ) > 2.3 )
961         setprop("tu154/systems/electrical/indicators/engine-1/revers-dampers",1.0);
962 else setprop("tu154/systems/electrical/indicators/engine-1/revers-dampers",0.0);
963 if( getprop( "fdm/jsbsim/propulsion/engine[2]/reverser-angle-rad" ) > 2.3 )
964         setprop("tu154/systems/electrical/indicators/engine-3/revers-dampers",1.0);
965 else setprop("tu154/systems/electrical/indicators/engine-3/revers-dampers",0.0);
966
967 #Hydrosystems 
968 if( getprop( "fdm/jsbsim/hs/hs1-pressure" ) < 100.0 )
969                         setprop("tu154/lamps/p-hydro-1",1.0);
970 else setprop("tu154/lamps/p-hydro-1",0.0);
971 if( getprop( "fdm/jsbsim/hs/hs2-pressure" ) < 100.0 )
972                         setprop("tu154/lamps/p-hydro-2",1.0);
973 else setprop("tu154/lamps/p-hydro-2",0.0);
974 if( getprop( "fdm/jsbsim/hs/hs3-pressure" ) < 100.0 )
975                         setprop("tu154/lamps/p-hydro-3",1.0);
976 else setprop("tu154/lamps/p-hydro-3",0.0);
977 if( getprop( "fdm/jsbsim/hs/emergency-brake-pressure" ) < 190.0 )
978                         setprop("tu154/lamps/p-hydro-brake",1.0);
979 else setprop("tu154/lamps/p-hydro-brake",0.0);
980
981 # Panel and ambient light
982 if( getprop( "tu154/switches/gauge-light" ) ) panel_lighting(1);
983 else panel_lighting(0);
984
985 # Nav light
986 if( getprop( "tu154/switches/bano" ) ) nav_lighting(1);
987 else nav_lighting(0);
988
989 # Strobes
990 if( getprop( "tu154/switches/omi" ) ) strobe_control(1);
991 else strobe_control(0);
992
993
994
995
996 }
997 # END indicator handler
998
999 #elev_trim_watchdog = func{
1000 #setprop("tu154/systems/warning/elevator-trim-pressed", 1.0 );
1001 #}
1002
1003 stab_watchdog = func{
1004 setprop("tu154/systems/warning/run-stabilizer", 1.0 );
1005 }
1006
1007 flap_watchdog = func{
1008 # flaps flag
1009 setprop("tu154/systems/warning/run-flaps", 1.0 );
1010 # RV-RN flag
1011 if( getprop("fdm/jsbsim/fcs/flap-pos-deg" ) < 10.0 )
1012                 {
1013                 setprop("tu154/systems/warning/rvrn/timeout", 1.0 );
1014                 # Time should be above 13 s 
1015                 interpolate("tu154/systems/warning/rvrn/timeout", 0.0, 3 );
1016                 }
1017 if( getprop( "controls/flight/flaps" ) < 0.1 )
1018     if( getprop("fdm/jsbsim/fcs/flap-pos-deg" ) > 10.0 )
1019         {
1020         setprop("tu154/systems/warning/rvrn/timeout", 1.0 );
1021         interpolate("tu154/systems/warning/rvrn/timeout", 0.0, 3 );
1022         }
1023 }
1024
1025 var flap_control_watchdog = func{
1026 if( getprop( "controls/flight/flaps" ) > 0.1 )
1027         setprop("tu154/systems/warning/deploy-flaps", 1.0 );
1028 }
1029
1030
1031 var strobe_control = func{
1032 if( arg[0] ){
1033         strobe.switch(1);
1034         }
1035 else    {
1036         strobe.switch(0);
1037         }
1038
1039 }
1040
1041
1042 var headlight_mode = func{
1043 var pwr = getprop("tu154/systems/electrical/buses/DC27-bus-L/volts");
1044 if( pwr == nil ) pwr = 0.0;
1045 if(  pwr > 13.0 ) {
1046         if( arg[0] == 2 or arg[0] == 0 ) {
1047                 if( arg[0] == 2 ) setprop("tu154/light/headlight-selector", 0.8 );
1048                 if( arg[0] == 0 ) setprop("tu154/light/headlight-selector", 1.0 );
1049                 }
1050         else {
1051                 setprop("tu154/light/headlight-selector", 0.0 );
1052                 }
1053         }
1054 else { # set off lamps, but not change position 
1055         setprop ("tu154/light/headlight-selector", 0.0 );       
1056         }
1057 }
1058
1059 var headlight_retract = func{
1060 var pwr = getprop("tu154/systems/electrical/buses/DC27-bus-L/volts");
1061 if( pwr == nil ) pwr = 0.0;
1062 if(  pwr > 13.0 ) {
1063         if( arg[0] ) interpolate("tu154/light/retract", 1.0, 2.0 );
1064         else interpolate("tu154/light/retract", 0.0, 2.0 );
1065         }
1066 }
1067
1068
1069
1070 # beacon_inner_watchdog = func{
1071 # if( getprop( "instrumentation/marker-beacon[0]/serviceable" ) > 0 )
1072 #       setprop("tu154/systems/electrical/indicators/beacon-inner", 1 );
1073 #  else setprop("tu154/systems/electrical/indicators/beacon-inner", 0 );
1074 # }
1075 # beacon_middle_watchdog = func{
1076 # if( getprop( "instrumentation/marker-beacon[0]/serviceable" ) > 0 )
1077 #       setprop("tu154/systems/electrical/indicators/beacon-middle", 
1078 #               getprop( "instrumentation/marker-beacon[0]/middle" ) );
1079 #  else setprop("tu154/systems/electrical/indicators/beacon-middle", 0 );
1080 # }
1081 # beacon_outer_watchdog = func{
1082 # if( getprop( "instrumentation/marker-beacon[0]/serviceable" ) > 0 )
1083 #       setprop("tu154/systems/electrical/indicators/beacon-outer", 
1084 #               getprop( "instrumentation/marker-beacon[0]/outer" ) );
1085 #  else setprop("tu154/systems/electrical/indicators/beacon-outer", 0 );
1086 # }
1087
1088
1089 setlistener( "tu154/systems/electrical/checking-lamps/main-panel",check_lamps_capt,1,0);
1090 setlistener( "surface-positions/flap-pos-norm", flap_watchdog, 1, 0 );
1091 setlistener( "controls/flight/flaps", flap_control_watchdog, 0, 0 );
1092 setlistener( "fdm/jsbsim/fcs/stabilizer-pos-rad", stab_watchdog, 1, 0 );
1093
1094
1095 #setlistener( "instrumentation/marker-beacon[0]/inner", beacon_inner_watchdog, 1, 0 );
1096 #setlistener( "instrumentation/marker-beacon[0]/middle", beacon_middle_watchdog, 1, 0 );
1097 #setlistener( "instrumentation/marker-beacon[0]/outer", beacon_middle_watchdog, 1, 0 );
1098 horn_handler();
1099 audio_handler();
1100 indicator_handler();
1101 voice_handler();
1102
1103
1104 print("Warning subsystem started");
1105