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