3 # Yurik V. Nikiforoff, yurik.nsk@gmail.com
5 # 2007 - 2008,2010,2013
8 #var HEADING_DEVIATION_LIMIT = 20.0;
9 #var GLIDESLOPE_DEVIATION_LIMIT = 10.0;
10 var PITCH_YOKE_LIMIT = 0.5;
11 var BANK_YOKE_LIMIT = 0.5;
13 var absu_property_update = func { # <- handler begin here
17 settimer( absu_property_update, 0 );
20 #var az1 = getprop("tu154/instrumentation/pn-5/az-1");
21 #if( az1 == nil ) az1 = 0.0;
22 var az2 = getprop("tu154/instrumentation/pn-5/az-2");
23 if( az2 == nil ) az2 = 0.0;
32 var radial_actual = "instrumentation/nav[1]/radials/actual-deg";
33 var radial_reciprocal = "instrumentation/nav[1]/radials/reciprocal-radial-deg";
34 var radial_selected = "instrumentation/nav[1]/radials/selected-deg";
35 var to_flag_prop = "instrumentation/nav[1]/to-flag";
38 var radial_actual = "instrumentation/nav[0]/radials/actual-deg";
39 var radial_reciprocal = "instrumentation/nav[0]/radials/reciprocal-radial-deg";
40 var radial_selected = "instrumentation/nav[0]/radials/selected-deg";
41 var to_flag_prop = "instrumentation/nav[0]/to-flag";
43 var to_flag = getprop( to_flag_prop );
44 if( to_flag == nil ) to_flag = 0.0;
45 if( to_flag ) param = getprop(radial_reciprocal);
46 else param = getprop(radial_actual);
47 if( param == nil ) param = 0.0;
48 var param2 = getprop(radial_selected);
49 if( param2 == nil ) param2 = 0.0;
50 param = param - param2;
51 if( param < -180.0 ) param = 360.0 + param;
52 if( param > 180.0 ) param = 360.0 - param;
53 if( to_flag ) param = -param;
54 setprop("fdm/jsbsim/ap/input-heading-delta", param);
56 #Delivery gyro heading to TKS compass system
57 param = getprop("orientation/heading-deg")+
58 getprop("instrumentation/heading-indicator[0]/offset-deg");
59 if( param < 0.0 ) param = param + 360.0;
60 if( param > 360.0 ) param = param - 360.0;
61 setprop("fdm/jsbsim/ap/input-heading-gyro-1", param);
63 param = getprop("orientation/heading-deg")+
64 getprop("instrumentation/heading-indicator[1]/offset-deg");
65 if( param < 0.0 ) param = param + 360.0;
66 if( param > 360.0 ) param = param - 360.0;
67 setprop("fdm/jsbsim/ap/input-heading-gyro-2", param);
69 #Delivery magnetic heading to TKS compass system
71 param = getprop("orientation/heading-magnetic-deg");
72 if( param == nil ) param = 0.0;
73 setprop("fdm/jsbsim/ap/input-magnetic-heading", param);
76 param = getprop("controls/gear/brake-left");
77 if( param == nil ) param = 0.0;
78 setprop("fdm/jsbsim/gear/brake-left", param);
79 param = getprop("controls/gear/brake-right");
80 if( param == nil ) param = 0.0;
81 setprop("fdm/jsbsim/gear/brake-right", param);
82 param = getprop("controls/gear/brake-parking");
83 if( param == nil ) param = 0.0;
84 setprop("fdm/jsbsim/gear/brake-parking", param);
85 # delivery steering parameters
86 param = getprop("controls/gear/steering");
87 if( param == nil ) param = 0.0;
88 setprop("fdm/jsbsim/gear/steering", param);
89 param = getprop("controls/gear/nose-wheel-steering");
90 if( param == nil ) param = 0.0;
91 setprop("fdm/jsbsim/gear/nose-wheel-steering", param);
98 var src_plane = "tu154/instrumentation/pnp[0]/plane-deg";
99 param = getprop("tu154/switches/pn-5-pnp-selector");
100 if( param == nil ) param = 0.0;
101 if( param ) src_plane = "tu154/instrumentation/pnp[1]/plane-deg";
102 param = getprop(src_plane);
103 if( param == nil ) param = 0.0;
104 setprop("fdm/jsbsim/ap/input-heading-pnp", param);
107 param = getprop("tu154/switches/zk-selector");
108 if( param == nil ) param = 0.0;
110 if( param ) src_plane = "tu154/instrumentation/pnp[1]/heading-deg";
111 else src_plane = "tu154/instrumentation/pnp[0]/heading-deg";
113 param = getprop(src_plane);
114 if( param == nil ) param = 0.0;
115 setprop("fdm/jsbsim/ap/input-heading-zk", param);
118 var needles = getprop("tu154/switches/pn-5-strelki" );
119 if( needles == nil ) needles = 0.0;
123 param = getprop("fdm/jsbsim/ap/pitch/gs-needle"); # Modified by Yurik nov 2103 for new ABSU version
125 if( param == nil ) param = 0.0;
126 if( getprop("fdm/jsbsim/ap/pitch-selector") != 5.0 ) param = 0.0;
127 setprop("tu154/instrumentation/pkp[0]/pitch-director", param );
129 param = getprop("fdm/jsbsim/ap/ils-out"); # Modified by Yurik nov 2103 for new ABSU version
131 if( param == nil ) param = 0.0;
132 if( getprop("fdm/jsbsim/ap/roll-selector") != 5.0 ) param = 0.0;
133 setprop("tu154/instrumentation/pkp[0]/roll-director", param );
136 interpolate("tu154/instrumentation/pkp[0]/pitch-director", 0.3, 1.0 );
137 interpolate("tu154/instrumentation/pkp[0]/roll-director", 0.3, 1.0 );
140 # Modified by Yurik dec 2103 for new ABSU version
141 # Glideslope auto switch
142 if( getprop("fdm/jsbsim/fcs/flap-pos-deg") > 40.0 )
143 if( getprop("fdm/jsbsim/ap/roll-selector") == 5.0 )
144 if( getprop("fdm/jsbsim/ap/pitch-selector") != 5.0 )
145 if( getprop("instrumentation/nav[0]/gs-needle-deflection") < 0.2 )
146 if( getprop("instrumentation/nav[0]/gs-needle-deflection") > 0.0 )
149 # Go around procedure
150 if( getprop("fdm/jsbsim/ap/pitch-selector") == 5.0 )
151 if( getprop("fdm/jsbsim/fcs/throttle-cmd-norm[0]") > 0.9 )
152 if( getprop("instrumentation/nav[0]/gs-in-range") )
153 absu_start_go_around();
162 var absu_stab_on = func {
163 if( absu_powered() == 0 ) return;
165 var kren = getprop("tu154/switches/pu-46-kren");
166 if( kren == nil ) kren = 0.0;
167 var tang = getprop("tu154/switches/pu-46-tang");
168 if( tang == nil ) tang = 0.0;
172 setprop("tu154/instrumentation/pu-46/stab", 1.0 );
174 setprop("fdm/jsbsim/ap/roll-hold", 1.0 );
179 setprop("tu154/instrumentation/pu-46/stab", 1.0 );
180 absu_stab_current_pitch();
181 setprop("fdm/jsbsim/ap/pitch-hold", 1.0 );
186 # Modified by Yurik dec 2013
187 # Go to manual control
188 var absu_stab_off = func {
190 # Clear audio warning if interpolation of is stale
191 setprop("tu154/systems/warning/alarm/absu_warn", 0.0 );
193 if( getprop("fdm/jsbsim/ap/pitch-hold") ) state = 1;
194 if( getprop("fdm/jsbsim/ap/roll-hold") ) state = state + 1;
195 if( getprop("tu154/instrumentation/pu-46/stab") ) state = state + 1;
196 if( getprop("tu154/instrumentation/pn-6/stab") ) state = state + 1;
197 if( state ) absu_alarm();
199 setprop("fdm/jsbsim/ap/roll-selector", 0.0 );
200 setprop("fdm/jsbsim/ap/pitch-selector", 0.0 );
201 setprop("fdm/jsbsim/ap/pitch-hold", 0.0 );
202 setprop("fdm/jsbsim/ap/roll-hold", 0.0 );
204 setprop("tu154/instrumentation/pu-46/stab", 0.0 );
206 setprop("fdm/jsbsim/ap/go-around", 0.0);
210 if( absu_powered() == 1 )
213 setprop( "tu154/instrumentation/pn-5/pitch-state", 1 );
214 setprop( "tu154/instrumentation/pn-5/heading-state", 1 );
215 setprop("tu154/instrumentation/pn-5/sbros", 1.0 );
218 setprop( "tu154/instrumentation/pn-5/pitch-state", 0 );
219 setprop( "tu154/instrumentation/pn-5/heading-state", 0 );
225 var absu_stab_kren = func {
227 var state = getprop("tu154/instrumentation/pu-46/stab");
228 if ( state == nil ) state = 0;
229 if ( arg[0] != 0 ) # start roll stabilizer
234 setprop("fdm/jsbsim/ap/roll-hold", 1.0 );
238 else # stop roll stabilizer
240 setprop("tu154/systems/electrical/indicators/nvu", 0.0 );
241 setprop("tu154/systems/electrical/indicators/vor", 0.0 );
242 setprop("tu154/systems/electrical/indicators/zk", 0.0 );
243 setprop("tu154/systems/electrical/indicators/heading", 0.0 );
244 setprop("tu154/systems/electrical/indicators/stab-heading", 0.0 );
245 setprop("fdm/jsbsim/ap/roll-hold", 0.0 );
246 if( absu_powered() == 1 )
249 setprop( "tu154/instrumentation/pn-5/heading-state", 1 );
251 if( getprop("tu154/switches/pu-46-tang") != 1.0 )
252 setprop("tu154/instrumentation/pu-46/stab", 0.0 );
257 var absu_stab_tang = func {
258 var state = getprop("tu154/instrumentation/pu-46/stab");
259 if ( state == nil ) state = 0;
260 if ( arg[0] != 0 ) # start pitch stabilizer
263 absu_stab_current_pitch();
264 setprop("fdm/jsbsim/ap/pitch-hold", 1.0 );
268 else # stop pitch stabilizer
271 setprop("fdm/jsbsim/ap/pitch-hold", 0.0 );
272 if( absu_powered() == 1 )
275 setprop( "tu154/instrumentation/pn-5/pitch-state", 1 );
277 if( getprop("tu154/switches/pu-46-kren") != 1.0 )
278 setprop("tu154/instrumentation/pu-46/stab", 0.0 );
285 var absu_powered = func{
286 if( getprop("tu154/systems/absu/serviceable" ) == 1 ) return 1;
290 var absu_stab_current_pitch = func{
291 setprop("fdm/jsbsim/ap/pitch-selector", 1.0 ); # 1 - stabilize pitch
292 setprop( "tu154/instrumentation/pn-5/pitch-state", 2 );
293 setprop("tu154/systems/electrical/indicators/stab-pitch", 1.0 );
296 var absu_stab_roll = func{
297 setprop("fdm/jsbsim/ap/stab-input-roll-rad", 0.0 ); # roll=0, stabilize wing level
298 setprop("fdm/jsbsim/ap/roll-selector", 1.0 ); # 1 - stabilize roll
299 setprop( "tu154/instrumentation/pn-5/heading-state", 2 );
300 setprop("tu154/systems/electrical/indicators/stab-heading", 1.0 );
303 var clr_heading_lamp = func{
305 setprop("tu154/instrumentation/pn-5/sbros", 0.0 );
306 setprop("tu154/instrumentation/pn-5/zk", 0.0 );
307 setprop("tu154/instrumentation/pn-5/nvu", 0.0 );
308 setprop("tu154/instrumentation/pn-5/az-1", 0.0 );
309 setprop("tu154/instrumentation/pn-5/az-2", 0.0 );
310 setprop("tu154/instrumentation/pn-5/zahod", 0.0 );
311 # Indicators on captain panel
312 setprop("tu154/systems/electrical/indicators/nvu", 0.0 );
313 setprop("tu154/systems/electrical/indicators/vor", 0.0 );
314 setprop("tu154/systems/electrical/indicators/zk", 0.0 );
315 setprop("tu154/systems/electrical/indicators/heading", 0.0 );
316 setprop("tu154/systems/electrical/indicators/stab-heading", 0.0 );
319 var clr_pitch_lamp = func{
320 setprop("tu154/instrumentation/pu-46/m", 0.0 );
321 setprop("tu154/instrumentation/pu-46/v", 0.0 );
322 setprop("tu154/instrumentation/pu-46/h", 0.0 );
323 setprop("tu154/instrumentation/pn-5/gliss", 0.0 );
324 # Indicators on captain panel
325 setprop("tu154/systems/electrical/indicators/glideslope", 0.0 );
326 setprop("tu154/systems/electrical/indicators/stab-pitch", 0.0 );
327 setprop("tu154/systems/electrical/indicators/stab-h", 0.0 );
328 setprop("tu154/systems/electrical/indicators/stab-v", 0.0 );
329 setprop("tu154/systems/electrical/indicators/stab-m", 0.0 );
330 setprop("tu154/systems/electrical/indicators/reject", 0.0 );
334 # "Sbros progr" lamp - reset AP to zero roll state
335 # also use in heading wheel animation
336 var absu_reset = func {
337 if( absu_powered() == 0 ) return;
339 setprop("fdm/jsbsim/ap/roll-selector", 0.0 );
340 setprop("tu154/instrumentation/pn-5/sbros", 1.0 );
341 if( getprop("fdm/jsbsim/ap/pitch-selector" ) == 5 )
342 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
343 absu_stab_current_pitch(); # Glideslope mode -> stab current pitch
345 setprop("tu154/instrumentation/pn-5/gliss", 0.0 );
346 setprop("tu154/systems/electrical/indicators/glideslope", 0.0 );
348 setprop("tu154/systems/electrical/indicators/reject", 0.0 );
350 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0
351 and getprop("tu154/switches/pu-46-kren" ) == 1.0 )
354 setprop("fdm/jsbsim/ap/roll-hold", 1.0 );
359 # --------------- Pitch modes ------------------------------
361 var absu_drop_mvh = func{
362 if( absu_powered() == 0 ) return;
363 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
364 if( getprop("fdm/jsbsim/ap/pitch-selector" ) != 1.0 )
367 setprop("fdm/jsbsim/ap/pitch-selector",0);
368 settimer( set_pitch_stab, 0.1 );
369 setprop("fdm/jsbsim/ap/pitch-hold",1);
370 if( getprop("tu154/switches/pu-46-tang" ) == 1.0 )
372 setprop( "tu154/instrumentation/pn-5/pitch-state", 2 );
373 setprop("tu154/systems/electrical/indicators/stab-pitch", 1.0 );
378 var set_pitch_stab = func{
379 setprop("fdm/jsbsim/ap/pitch-selector",1 );
383 # Clear MET to neutral
385 var absu_met_neutral = func{
386 setprop("fdm/jsbsim/ap/met-neutral", 1 );
387 settimer( enable_met, 0.1 );
390 var enable_met = func{
391 setprop("fdm/jsbsim/ap/met-neutral", 0 );
396 # Altitude stabilizer
398 if( absu_powered() == 0 ) return;
400 var alt = getprop("instrumentation/altimeter[0]/pressure-alt-ft"); # Modified by Yurik dec 2013
402 setprop("fdm/jsbsim/ap/input-altitude", alt );
403 setprop("fdm/jsbsim/ap/pitch-selector", 2 ); # H stab code
404 setprop("tu154/instrumentation/pu-46/h", 1.0 );
405 if( getprop("tu154/switches/pu-46-tang" ) == 1.0 )
406 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
407 setprop("tu154/systems/electrical/indicators/stab-h", 1.0 );
410 # Air speed stabilizer
412 if( absu_powered() == 0 ) return;
413 var ias = getprop("fdm/jsbsim/velocities/vc-fps");
415 setprop("fdm/jsbsim/ap/input-speed", ias );
416 setprop("fdm/jsbsim/ap/pitch-selector", 3 ); # V stab code
417 setprop("tu154/instrumentation/pu-46/v", 1.0 );
418 if( getprop("tu154/switches/pu-46-tang" ) == 1.0 )
419 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
420 setprop("tu154/systems/electrical/indicators/stab-v", 1.0 );
425 if( absu_powered() == 0 ) return;
426 var mach = getprop("fdm/jsbsim/velocities/mach");
427 #if ( mach == nil ) return;
429 setprop("fdm/jsbsim/ap/input-mach", mach );
430 setprop("fdm/jsbsim/ap/pitch-selector", 4 ); # M stab code
431 setprop("tu154/instrumentation/pu-46/m", 1.0 );
432 if( getprop("tu154/switches/pu-46-tang" ) == 1.0 )
433 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
434 setprop("tu154/systems/electrical/indicators/stab-m", 1.0 );
438 var absu_glideslope = func{
439 if( absu_powered() == 0 ) return;
440 if( getprop("tu154/switches/pn-5-posadk") != 1.0)return;# "podgotovka posadki" not engaged
441 if( getprop("tu154/switches/pn-5-navigac" ) != 0.0 ) return; # wrong control!
444 setprop("tu154/instrumentation/pn-5/sbros", 0.0 );
445 setprop("fdm/jsbsim/ap/pitch-selector", 5.0 ); # Glideslope code
446 setprop("tu154/instrumentation/pn-5/gliss", 1.0 );
447 if( getprop("tu154/switches/pu-46-tang" ) == 1.0 )
448 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
449 setprop("tu154/systems/electrical/indicators/glideslope", 1.0 );
452 # --------------- Heading modes ------------------------------
456 if( absu_powered() == 0 ) return;
459 setprop("fdm/jsbsim/ap/roll-selector", 2 ); # ZK code
460 setprop("tu154/instrumentation/pn-5/zk", 1.0 );
461 if( getprop("tu154/switches/pu-46-kren" ) == 1.0 )
462 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 )
463 setprop("tu154/systems/electrical/indicators/zk", 1.0);
467 if( absu_powered() == 0 ) return;
471 setprop("tu154/instrumentation/pn-5/az-1", 1.0 );
472 setprop("fdm/jsbsim/ap/roll-selector", 3 ); # VOR code
474 if( getprop("tu154/switches/pu-46-kren" ) == 1.0 )
475 if( getprop("tu154/instrumentation/pu-46/stab") == 1.0) {
476 if(getprop("tu154/switches/pn-5-navigac") == 1.0 and
477 getprop("tu154/switches/pn-5-posadk") == 0.0)
478 setprop("tu154/systems/electrical/indicators/vor", 1.0);
480 setprop("tu154/systems/electrical/indicators/stab-heading", 1.0);
485 if( absu_powered() == 0 ) return;
489 setprop("tu154/instrumentation/pn-5/az-2", 1.0 );
490 setprop("fdm/jsbsim/ap/roll-selector", 3 ); # VOR code
491 if( getprop("tu154/switches/pu-46-kren" ) == 1.0 )
492 if( getprop("tu154/instrumentation/pu-46/stab") == 1.0) {
493 if(getprop("tu154/switches/pn-5-navigac") == 1.0 and
494 getprop("tu154/switches/pn-5-posadk") == 0.0)
495 setprop("tu154/systems/electrical/indicators/vor", 1.0);
497 setprop("tu154/systems/electrical/indicators/stab-heading", 1.0);
502 if( absu_powered() == 0 ) return;
505 setprop("fdm/jsbsim/ap/roll-selector", 4 ); # NVU code
506 setprop("tu154/instrumentation/pn-5/nvu", 1.0 );
507 if( getprop("tu154/switches/pu-46-kren" ) == 1.0 )
508 if( getprop("tu154/instrumentation/pu-46/stab") == 1.0) {
509 if(getprop("tu154/switches/pn-5-navigac") == 1.0 and
510 getprop("tu154/switches/pn-5-posadk") == 0.0)
511 setprop("tu154/systems/electrical/indicators/nvu", 1.0);
513 setprop("tu154/systems/electrical/indicators/stab-heading", 1.0);
518 var absu_approach = func{
519 if( absu_powered() == 0 ) return;
522 setprop("fdm/jsbsim/ap/roll-selector", 5 ); # ILS approach code
523 setprop("tu154/instrumentation/pn-5/zahod", 1.0 );
524 if( getprop("tu154/switches/pu-46-kren" ) == 1.0 )
525 if( getprop("tu154/instrumentation/pu-46/stab" ) == 1.0 ) {
526 if(getprop("tu154/switches/pn-5-navigac") == 0.0 and
527 getprop("tu154/switches/pn-5-posadk") == 1.0)
528 setprop("tu154/systems/electrical/indicators/heading", 1.0 );
530 setprop("tu154/systems/electrical/indicators/stab-heading", 1.0);
536 var absu_shutdown = func {
537 # Drop ABSU to idle state
541 setprop("tu154/systems/electrical/indicators/stab-heading", 0.0 );
542 setprop("tu154/systems/electrical/indicators/stab-pitch", 0.0 );
544 if( getprop( "tu154/systems/absu/serviceable" ) == 0 )
553 var absu_alarm = func{
554 setprop("tu154/systems/warning/alarm/absu_warn", 1.0 );
555 interpolate("tu154/systems/warning/alarm/absu_warn", 0.0, 1.4 );
558 var absu_alarm_watchdog = func{
559 if( getprop("tu154/systems/warning/alarm/absu_warn") < 0.1 )
560 setprop("tu154/systems/warning/alarm/absu_warn", 0.0 );
564 setlistener("tu154/systems/absu/serviceable", absu_shutdown, 0, 0 );
565 setlistener("tu154/systems/absu/serviceable", absu_alarm, 0, 0 );
566 setlistener("tu154/systems/warning/alarm/absu_warn", absu_alarm_watchdog, 0, 0 );
568 absu_property_update();
570 # ********************** Go around procedure ********************************
572 var absu_start_go_around = func{
575 absu_stab_current_pitch();
576 # Modified by Yurik dec 2013
577 # for new AP JSBSim system
579 setprop("fdm/jsbsim/ap/pitch-selector", 6.0);
580 setprop("fdm/jsbsim/ap/roll-selector", 1.0);
582 # Blank indicators, but stay button-lamps on PN-5 untouched
583 setprop("tu154/systems/electrical/indicators/nvu", 0.0 );
584 setprop("tu154/systems/electrical/indicators/vor", 0.0 );
585 setprop("tu154/systems/electrical/indicators/zk", 0.0 );
586 setprop("tu154/systems/electrical/indicators/heading", 0.0 );
588 setprop("tu154/systems/electrical/indicators/glideslope", 0.0 );
589 setprop("tu154/systems/electrical/indicators/stab-pitch", 0.0 );
590 setprop("tu154/systems/electrical/indicators/stab-h", 0.0 );
591 setprop("tu154/systems/electrical/indicators/stab-v", 0.0 );
592 setprop("tu154/systems/electrical/indicators/stab-m", 0.0 );
593 setprop("tu154/systems/electrical/indicators/reject", 0.0 );
595 setprop("tu154/systems/electrical/indicators/reject", 1.0 );
596 setprop("tu154/systems/electrical/indicators/stab-heading", 1.0 );
599 # ========================== yoke ap off =============================
600 var check_yoke_pitch = func{
601 var pitch = abs( getprop("/controls/flight/elevator") );
602 if( pitch < PITCH_YOKE_LIMIT ) return;
603 if( getprop( "fdm/jsbsim/ap/pitch-hold" ) ) absu_stab_tang(0); # drop pitch stabilizer
605 var check_yoke_bank = func{
606 var bank = abs( getprop("/controls/flight/aileron") );
607 if( bank < BANK_YOKE_LIMIT ) return;
608 if( getprop( "fdm/jsbsim/ap/roll-hold" ) ) absu_stab_kren(0); # drop roll
611 setlistener("/controls/flight/elevator", check_yoke_pitch, 0, 0 );
612 setlistener("/controls/flight/aileron", check_yoke_bank, 0, 0 );
614 # ================== AT-6 autothrottle subsystem =====================
617 var absu_at_handler = func(param) {
619 { # drop to power off state
621 setprop("tu154/instrumentation/pn-6/g1", 0 );
622 setprop("tu154/instrumentation/pn-6/g2", 0 );
623 setprop("tu154/instrumentation/pn-6/g3", 0 );
624 # setprop("tu154/instrumentation/pn-6/lamp-1", 0.0 );
625 # setprop("tu154/instrumentation/pn-6/lamp-2", 0.0 );
626 # setprop("tu154/instrumentation/pn-6/lamp-3", 0.0 );
627 setprop("tu154/instrumentation/pn-6/lamp-4", 0.0 );
628 setprop("tu154/instrumentation/pn-6/lamp-5", 0.0 );
629 setprop("tu154/instrumentation/pn-6/stab", 0 );
630 setprop("tu154/instrumentation/pn-6/mode", 0.0 );
631 setprop("tu154/systems/electrical/indicators/autothrottle", 0.0 );
632 setprop("fdm/jsbsim/ap/at-podg", 0.0 );
635 if( param == 1.0 ) # power on ( mode "soglasovanie" )
637 setprop("tu154/instrumentation/pn-6/mode", 1.0 );
638 setprop("fdm/jsbsim/ap/at-podg", 1.0 );
639 absu_at_sogl(); # start "soglasovanie" cycle
644 if( param == 2.0 ) # mode "podgotovka" off
646 if( getprop( "tu154/instrumentation/pn-6/mode" ) >= 1.0 )
649 setprop("tu154/instrumentation/pn-6/mode", 1.0 );
653 if( param == 3.0 ) # mode "podgotovka" on
656 #print( getprop("tu154/instrumentation/pn-6/mode") );
657 if( getprop("tu154/instrumentation/pn-6/mode") >= 1.0 )
659 interpolate("tu154/instrumentation/pn-6/mode", 3.0, 10.0 );
664 setlistener("tu154/instrumentation/pn-6/serviceable", func {
665 absu_at_handler(getprop("tu154/instrumentation/pn-6/serviceable"));
669 # ABSU AT timer procedure
670 var absu_at_sogl = func{
671 if( getprop("tu154/instrumentation/pn-6/mode") == 0.0 ) return;
672 settimer( absu_at_sogl, 0.3 );
676 if( getprop("tu154/instrumentation/pn-6/mode") > 2.0 )
678 setprop("tu154/instrumentation/pn-6/lamp-4", 1.0 );
679 setprop("tu154/instrumentation/pn-6/lamp-5", 1.0 );
683 setprop("tu154/instrumentation/pn-6/lamp-4", 0.0 );
684 setprop("tu154/instrumentation/pn-6/lamp-5", 0.0 );
688 if( getprop("tu154/instrumentation/pn-6/stab") == 0 ) # soglasovanie
690 setprop("fdm/jsbsim/ap/at-podg", 1.0 );
691 setprop("fdm/jsbsim/ap/at-hold-0", 0.0 );
692 setprop("fdm/jsbsim/ap/at-hold-1", 0.0 );
693 setprop("fdm/jsbsim/ap/at-hold-2", 0.0 );
695 var kias = getprop("instrumentation/airspeed-indicator/indicated-speed-kt");
696 if( kias != nil ) interpolate("tu154/instrumentation/pn-6/at-kt", kias, 0.3);
699 var kias = getprop("tu154/instrumentation/pn-6/at-kt");
700 if( kias != nil ) setprop( "fdm/jsbsim/ap/input-at", kias*1.688 ); # from knots to fps
701 absu_at_check_thr(); # check off-line state
708 var absu_at_check = func{
709 if( getprop("tu154/instrumentation/pn-6/mode") > 2.0 )
712 setprop("tu154/instrumentation/pn-6/lamp-4", state );
713 setprop("tu154/instrumentation/pn-6/lamp-5", state );
714 # setprop("tu154/instrumentation/pn-6/check-lamp", state );
719 # Start stabilize speed
720 var absu_at_start = func{
721 if( getprop("tu154/instrumentation/pn-6/mode") < 2.0 ) return;
722 if( absu_at_check_thr() ) return; # 2 or 3 engines are offline now
723 # Set AT to stab mode
724 var kias = getprop("instrumentation/airspeed-indicator/indicated-speed-kt");
726 interpolate("tu154/instrumentation/pn-6/at-kt", kias, 0.3);
727 setprop("fdm/jsbsim/ap/input-at", kias*1.688 );
730 setprop("fdm/jsbsim/ap/at-hold-0", 1.0 );
731 setprop("fdm/jsbsim/ap/at-hold-1", 1.0 );
732 setprop("fdm/jsbsim/ap/at-hold-2", 1.0 );
735 setprop("tu154/instrumentation/pn-6/stab", 1.0 );
736 setprop("tu154/systems/electrical/indicators/autothrottle", 1.0 );
739 # Stop stabilize speed
740 var absu_at_stop = func{
741 var thr_pos0 = getprop("fdm/jsbsim/fcs/throttle-pos-norm[0]");
742 var thr_pos1 = getprop("fdm/jsbsim/fcs/throttle-pos-norm[1]");
743 var thr_pos2 = getprop("fdm/jsbsim/fcs/throttle-pos-norm[2]");
744 setprop("controls/engines/engine[0]/throttle", thr_pos0);
745 setprop("controls/engines/engine[1]/throttle", thr_pos1);
746 setprop("controls/engines/engine[2]/throttle", thr_pos2);
748 setprop("fdm/jsbsim/ap/at-podg", 1.0 );
749 setprop("fdm/jsbsim/ap/at-hold-0", 0.0 );
750 setprop("fdm/jsbsim/ap/at-hold-1", 0.0 );
751 setprop("fdm/jsbsim/ap/at-hold-2", 0.0 );
753 setprop("tu154/instrumentation/pn-6/lamp-4", 0.0 );
754 setprop("tu154/instrumentation/pn-6/lamp-5", 0.0 );
756 if( getprop("tu154/instrumentation/pn-6/stab" ) ) absu_alarm();
758 setprop("tu154/instrumentation/pn-6/stab", 0.0 );
760 setprop("tu154/systems/electrical/indicators/autothrottle", 0.0 );
764 var absu_at_check_thr = func{
765 # Check off-line engines
766 var eng_1 = getprop( "tu154/instrumentation/pn-6/g1" );
767 if( eng_1 == nil ) eng_1 = 0;
768 var eng_2 = getprop( "tu154/instrumentation/pn-6/g2" );
769 if( eng_2 == nil ) eng_2 = 0;
770 var eng_3 = getprop( "tu154/instrumentation/pn-6/g3" );
771 if( eng_3 == nil ) eng_3 = 0;
773 if( (eng_1 + eng_2 + eng_3) > 1.0 ) {
777 if( eng_1 ) setprop("fdm/jsbsim/ap/at-hold-0", 0.0 );
778 else setprop("fdm/jsbsim/ap/at-hold-0", 1.0 );
779 if( eng_2 ) setprop("fdm/jsbsim/ap/at-hold-1", 0.0 );
780 else setprop("fdm/jsbsim/ap/at-hold-1", 1.0 );
781 if( eng_3 ) setprop("fdm/jsbsim/ap/at-hold-2", 0.0 );
782 else setprop("fdm/jsbsim/ap/at-hold-2", 1.0 );
788 var acpwr = getprop( "tu154/systems/electrical/buses/AC3x200-bus-3L/volts" );
789 var mgv1 = getprop("tu154/instrumentation/bkk/mgv-1-failure");
790 if( mgv1 == nil ) mgv1 = 1;
791 var mgv2 = getprop("tu154/instrumentation/bkk/mgv-2-failure");
792 if( mgv2 == nil ) mgv2 = 1;
793 var mgvc = getprop("tu154/instrumentation/bkk/mgv-contr-failure");
794 if( mgvc == nil ) mgvc = 1;
796 if( getprop("tu154/switches/SAU-STU")==1 )
798 if( acpwr == nil ) return; # system not ready yet
799 if( acpwr < 150.0 ) return;
800 # hydrosystem fails or busters off
801 if( getprop("fdm/jsbsim/hs/busters-serviceable") < 2.5 ) return;
803 var mgv = mgv1 + mgv2 + mgvc;
804 if( mgv > 1 ) return; # deny stab autopilot if all MGV failure
805 # check hydropower of RA-56
806 if( getprop("fdm/jsbsim/hs/ra-56-roll-serviceable") < 1.0 ) return;
807 if( getprop("fdm/jsbsim/hs/ra-56-yaw-serviceable") < 1.0 ) return;
808 if( getprop("fdm/jsbsim/hs/ra-56-pitch-serviceable") < 1.0 ) return;
809 if( getprop("fdm/jsbsim/ap/suu-enable") != 1.0 ) return;
810 # All OK, let's turn power on for ABSU
811 setprop("tu154/systems/absu/serviceable", 1 );
812 electrical.AC3x200_bus_3R.add_output( "ABSU", 100.0);
815 setprop("tu154/systems/absu/serviceable", 0 );
816 electrical.AC3x200_bus_3R.rm_output( "ABSU" );
822 setlistener("tu154/switches/SAU-STU", absu_power, 0, 0 );
823 # ============================== End AT-6 support ===========================
825 gui.Dialog.new("/sim/gui/dialogs/Tu-154B-2/nav/dialog", "Aircraft/tu154b/Dialogs/nav.xml");
828 setprop("sim/menubar/default/menu[3]/enabled", 0 );
830 print("ABSU started, default autopilot disabled");