1var input = func(v) {
2		setprop("/instrumentation/cdu/input",getprop("/instrumentation/cdu/input")~v);
3	}
4
5var input = func(v) {
6		setprop("/instrumentation/cdu/input",getprop("/instrumentation/cdu/input")~v);
7	}
8
9var key = func(v) {
10		var cduDisplay = getprop("/instrumentation/cdu/display");
11		var serviceable = getprop("/instrumentation/cdu/serviceable");
12		var eicasDisplay = getprop("/instrumentation/eicas/display");
13		var cduInput = getprop("/instrumentation/cdu/input");
14
15		if (serviceable == 1){
16			if (v == "LSK1L"){
17				if (cduDisplay == "DEP_ARR_INDEX"){
18					cduDisplay = "RTE1_DEP";
19				}
20				if (cduDisplay == "EICAS_MODES"){
21					eicasDisplay = "ENG";
22				}
23				if (cduDisplay == "EICAS_SYN"){
24					eicasDisplay = "ELEC";
25				}
26				if (cduDisplay == "INIT_REF"){
27					cduDisplay = "IDENT";
28				}
29				if (cduDisplay == "NAV_RAD"){
30					setprop("/instrumentation/nav[0]/frequencies/selected-mhz",cduInput);
31					cduInput = "";
32				}
33				if (cduDisplay == "RTE1_1"){
34					setprop("/autopilot/route-manager/departure/airport",cduInput);
35					cduInput = "";
36				}
37				if (cduDisplay == "RTE1_LEGS"){
38					if (cduInput == "DELETE"){
39						setprop("/autopilot/route-manager/input","@DELETE1");
40						cduInput = "";
41					}
42					else{
43						setprop("/autopilot/route-manager/input","@INSERT2:"~cduInput);
44					}
45				}
46				if (cduDisplay == "TO_REF"){
47					setprop("/instrumentation/fmc/to-flap",cduInput);
48					cduInput = "";
49				}
50			}
51			if (v == "LSK1R"){
52				if (cduDisplay == "EICAS_MODES"){
53					eicasDisplay = "FUEL";
54				}
55				if (cduDisplay == "EICAS_SYN"){
56					eicasDisplay = "HYD";
57				}
58				if (cduDisplay == "NAV RAD"){
59					setprop("/instrumentation/nav[1]/frequencies/selected-mhz",cduInput);
60					cduInput = "";
61				}
62				if (cduDisplay == "RTE1_1"){
63					setprop("/autopilot/route-manager/destination/airport",cduInput);
64					cduInput = "";
65				}
66				if (cduDisplay == "RTE1_LEGS"){
67					setprop("/autopilot/route-manager/route/wp[1]/altitude-ft",cduInput);
68					if (substr(cduInput,0,2) == "FL"){
69						setprop("/autopilot/route-manager/route/wp[1]/altitude-ft",substr(cduInput,2)*100);
70					}
71					cduInput = "";
72				}
73			}
74			if (v == "LSK2L"){
75				if (cduDisplay == "EICAS_MODES"){
76					eicasDisplay = "STAT";
77				}
78				if (cduDisplay == "EICAS_SYN"){
79					eicasDisplay = "ECS";
80				}
81				if (cduDisplay == "POS_INIT"){
82					setprop("/instrumentation/fmc/ref-airport",cduInput);
83					cduInput = "";;
84				}
85				if (cduDisplay == "INIT_REF"){
86					cduDisplay = "POS_INIT";
87				}
88				if (cduDisplay == "RTE1_1"){
89					setprop("/autopilot/route-manager/departure/runway",cduInput);
90					cduInput = "";;
91				}
92				if (cduDisplay == "RTE1_LEGS"){
93					if (cduInput == "DELETE"){
94						setprop("/autopilot/route-manager/input","@DELETE2");
95						cduInput = "";
96					}
97					else{
98						setprop("/autopilot/route-manager/input","@INSERT3:"~cduInput);
99					}
100				}
101			}
102			if (v == "LSK2R"){
103				if (cduDisplay == "DEP_ARR_INDEX"){
104					cduDisplay = "RTE1_ARR";
105				}
106				else if (cduDisplay == "EICAS_MODES"){
107					eicasDisplay = "GEAR";
108				}
109				else if (cduDisplay == "EICAS_SYN"){
110					eicasDisplay = "DRS";
111				}
112				else if (cduDisplay == "MENU"){
113					eicasDisplay = "EICAS_MODES";
114				}
115				else if (cduDisplay == "RTE1_LEGS"){
116					setprop("/autopilot/route-manager/route/wp[2]/altitude-ft",cduInput);
117					if (substr(cduInput,0,2) == "FL"){
118						setprop("/autopilot/route-manager/route/wp[2]/altitude-ft",substr(cduInput,2)*100);
119					}
120					cduInput = "";
121				}
122			}
123			if (v == "LSK3L"){
124				if (cduDisplay == "INIT_REF"){
125					cduDisplay = "PERF_INIT";
126				}
127				if (cduDisplay == "RTE1_LEGS"){
128					if (cduInput == "DELETE"){
129						setprop("/autopilot/route-manager/input","@DELETE3");
130						cduInput = "";
131					}
132					else{
133						setprop("/autopilot/route-manager/input","@INSERT4:"~cduInput);
134					}
135				}
136			}
137			if (v == "LSK3R"){
138				if (cduDisplay == "RTE1_LEGS"){
139					setprop("/autopilot/route-manager/route/wp[3]/altitude-ft",cduInput);
140					if (substr(cduInput,0,2) == "FL"){
141						setprop("/autopilot/route-manager/route/wp[3]/altitude-ft",substr(cduInput,2)*100);
142					}
143					cduInput = "";
144				}
145			}
146			if (v == "LSK4L"){
147				if (cduDisplay == "INIT_REF"){
148					cduDisplay = "THR_LIM";
149				}
150				if (cduDisplay == "RTE1_LEGS"){
151					if (cduInput == "DELETE"){
152						setprop("/autopilot/route-manager/input","@DELETE4");
153						cduInput = "";
154					}
155					else{
156						setprop("/autopilot/route-manager/input","@INSERT5:"~cduInput);
157					}
158				}
159			}
160			if (v == "LSK4R"){
161				if (cduDisplay == "RTE1_LEGS"){
162					setprop("/autopilot/route-manager/route/wp[4]/altitude-ft",cduInput);
163					if (substr(cduInput,0,2) == "FL"){
164						setprop("/autopilot/route-manager/route/wp[4]/altitude-ft",substr(cduInput,2)*100);
165					}
166					cduInput = "";
167				}
168			}
169			if (v == "LSK5L"){
170				if (cduDisplay == "INIT_REF"){
171					cduDisplay = "TO_REF";
172				}
173				if (cduDisplay == "RTE1_LEGS"){
174					if (cduInput == "DELETE"){
175						setprop("/autopilot/route-manager/input","@DELETE5");
176						cduInput = "";
177					}
178					else{
179						setprop("/autopilot/route-manager/input","@INSERT6:"~cduInput);
180					}
181				}
182			}
183			if (v == "LSK5R"){
184				if (cduDisplay == "RTE1_LEGS"){
185					setprop("/autopilot/route-manager/route/wp[5]/altitude-ft",cduInput);
186					if (substr(cduInput,0,2) == "FL"){
187						setprop("/autopilot/route-manager/route/wp[5]/altitude-ft",substr(cduInput,2)*100);
188					}
189					cduInput = "";
190				}
191			}
192			if (v == "LSK6L"){
193				if (cduDisplay == "INIT_REF"){
194					cduDisplay = "APP_REF";
195				}
196				if (cduDisplay == "APP_REF"){
197					cduDisplay = "INIT_REF";
198				}
199				if ((cduDisplay == "IDENT") or (cduDisplay = "MAINT") or (cduDisplay = "PERF_INIT") or (cduDisplay = "POS_INIT") or (cduDisplay = "POS_REF") or (cduDisplay = "THR_LIM") or (cduDisplay = "TO_REF")){
200					cduDisplay = "INIT_REF";
201				}
202			}
203			if (v == "LSK6R"){
204				if (cduDisplay == "THR_LIM"){
205					cduDisplay = "TO_REF";
206				}
207				else if (cduDisplay == "APP_REF"){
208					cduDisplay = "THR_LIM";
209				}
210				else if ((cduDisplay == "RTE1_1") or (cduDisplay == "RTE1_LEGS")){
211					setprop("/autopilot/route-manager/input","@ACTIVATE");
212				}
213				else if ((cduDisplay == "POS_INIT") or (cduDisplay == "DEP") or (cduDisplay == "RTE1_ARR") or (cduDisplay == "RTE1_DEP")){
214					cduDisplay = "RTE1_1";
215				}
216				else if ((cduDisplay == "IDENT") or (cduDisplay == "TO_REF")){
217					cduDisplay = "POS_INIT";
218				}
219				else if (cduDisplay == "EICAS_SYN"){
220					cduDisplay = "EICAS_MODES";
221				}
222				else if (cduDisplay == "EICAS_MODES"){
223					cduDisplay = "EICAS_SYN";
224				}
225				else if (cduDisplay == "INIT_REF"){
226					cduDisplay = "MAINT";
227				}
228			}
229
230			setprop("/instrumentation/cdu/display",cduDisplay);
231			if (eicasDisplay != nil){
232				setprop("/instrumentation/eicas/display",eicasDisplay);
233			}
234			setprop("/instrumentation/cdu/input",cduInput);
235		}
236	}
237
238var delete = func {
239		var length = size(getprop("/instrumentation/cdu/input")) - 1;
240		setprop("/instrumentation/cdu/input",substr(getprop("/instrumentation/cdu/input"),0,length));
241	}
242
243var i = 0;
244
245var plusminus = func {
246	var end = size(getprop("/instrumentation/cdu/input"));
247	var start = end - 1;
248	var lastchar = substr(getprop("/instrumentation/cdu/input"),start,end);
249	if (lastchar == "+"){
250		me.delete();
251		me.input('-');
252		}
253	if (lastchar == "-"){
254		me.delete();
255		me.input('+');
256		}
257	if ((lastchar != "-") and (lastchar != "+")){
258		me.input('+');
259		}
260	}
261
262var cdu = func{
263
264		var display = getprop("/instrumentation/cdu/display");
265		var serviceable = getprop("/instrumentation/cdu/serviceable");
266		title = "";		page = "";
267		line1l = "";	line2l = "";	line3l = "";	line4l = "";	line5l = "";	line6l = "";
268		line1lt = "";	line2lt = "";	line3lt = "";	line4lt = "";	line5lt = "";	line6lt = "";
269		line1c = "";	line2c = "";	line3c = "";	line4c = "";	line5c = "";	line6c = "";
270		line1ct = "";	line2ct = "";	line3ct = "";	line4ct = "";	line5ct = "";	line6ct = "";
271		line1r = "";	line2r = "";	line3r = "";	line4r = "";	line5r = "";	line6r = "";
272		line1rt = "";	line2rt = "";	line3rt = "";	line4rt = "";	line5rt = "";	line6rt = "";
273
274		if (display == "MENU") {
275			title = "MENU";
276			line1l = "<FMC";
277			line1rt = "EFIS CP";
278			line1r = "SELECT>";
279			line2l = "<ACARS";
280			line2rt = "EICAS CP";
281			line2r = "SELECT>";
282			line6l = "<ACMS";
283			line6r = "CMC>";
284		}
285		if (display == "ALTN_NAV_RAD") {
286			title = "ALTN NAV RADIO";
287		}
288		if (display == "APP_REF") {
289			title = "APPROACH REF";
290			line1lt = "GROSS WT";
291			line1rt = "FLAPS    VREF";
292			if (getprop("/instrumentation/fmc/vspeeds/Vref") != nil){
293				line1l = getprop("/instrumentation/fmc/vspeeds/Vref");
294			}
295			if (getprop("/autopilot/route-manager/destination/airport") != nil){
296				line4lt = getprop("/autopilot/route-manager/destination/airport");
297			}
298			line6l = "<INDEX";
299			line6r = "THRUST LIM>";
300		}
301		if (display == "DEP_ARR_INDEX") {
302			title = "DEP/ARR INDEX";
303			line1l = "<DEP";
304			line1ct = "RTE 1";
305			if (getprop("/autopilot/route-manager/departure/airport") != nil){
306				line1c = getprop("/autopilot/route-manager/departure/airport");
307			}
308			line1r = "ARR>";
309			if (getprop("/autopilot/route-manager/destination/airport") != nil){
310				line2c = getprop("/autopilot/route-manager/destination/airport");
311			}
312			line2r = "ARR>";
313			line3l = "<DEP";
314			line3r = "ARR>";
315			line4r = "ARR>";
316			line6lt ="DEP";
317			line6l = "<----";
318			line6c = "OTHER";
319			line6rt ="ARR";
320			line6r = "---->";
321		}
322		if (display == "EICAS_MODES") {
323			title = "EICAS MODES";
324			line1l = "<ENG";
325			line1r = "FUEL>";
326			line2l = "<STAT";
327			line2r = "GEAR>";
328			line5l = "<CANC";
329			line5r = "RCL>";
330			line6r = "SYNOPTICS>";
331		}
332		if (display == "EICAS_SYN") {
333			title = "EICAS SYNOPTICS";
334			line1l = "<ELEC";
335			line1r = "HYD>";
336			line2l = "<ECS";
337			line2r = "DOORS>";
338			line5l = "<CANC";
339			line5r = "RCL>";
340			line6r = "MODES>";
341		}
342		if (display == "FIX_INFO") {
343			title = "FIX INFO";
344			line1l = sprintf("%3.2f", getprop("/instrumentation/nav[0]/frequencies/selected-mhz-fmt"));
345			line1r = sprintf("%3.2f", getprop("/instrumentation/nav[1]/frequencies/selected-mhz-fmt"));
346			line2l = sprintf("%3.2f", getprop("/instrumentation/nav[0]/radials/selected-deg"));
347			line2r = sprintf("%3.2f", getprop("/instrumentation/nav[1]/radials/selected-deg"));
348			line6l = "<ERASE FIX";
349		}
350		if (display == "IDENT") {
351			title = "IDENT";
352			line1lt = "MODEL";
353			if (getprop("/instrumentation/cdu/ident/model") != nil){
354				line1l = getprop("/instrumentation/cdu/ident/model");
355			}
356			line1rt = "ENGINES";
357			line2lt = "NAV DATA";
358			if (getprop("/instrumentation/cdu/ident/engines") != nil){
359				line1r = getprop("/instrumentation/cdu/ident/engines");
360			}
361			line6l = "<INDEX";
362			line6r = "POS INIT>";
363		}
364		if (display == "INIT_REF") {
365			title = "INIT/REF INDEX";
366			line1l = "<IDENT";
367			line1r = "NAV DATA>";
368			line2l = "<POS";
369			line3l = "<PERF";
370			line4l = "<THRUST LIM";
371			line5l = "<TAKEOFF";
372			line6l = "<APPROACH";
373			line6r = "MAINT>";
374		}
375		if (display == "MAINT") {
376			title = "MAINTENANCE INDEX";
377			line1l = "<CROS LOAD";
378			line1r = "BITE>";
379			line2l = "<PERF FACTORS";
380			line3l = "<IRS MONITOR";
381			line6l = "<INDEX";
382		}
383		if (display == "NAV_RAD") {
384			title = "NAV RADIO";
385			line1lt = "VOR L";
386			line1l = sprintf("%3.2f", getprop("/instrumentation/nav[0]/frequencies/selected-mhz-fmt"));
387			line1rt = "VOR R";
388			line1r = sprintf("%3.2f", getprop("/instrumentation/nav[1]/frequencies/selected-mhz-fmt"));
389			line2lt = "CRS";
390			line2ct = "RADIAL";
391			line2c = sprintf("%3.2f", getprop("/instrumentation/nav[0]/radials/selected-deg"))~"   "~sprintf("%3.2f", getprop("/instrumentation/nav[1]/radials/selected-deg"));
392			line2rt = "CRS";
393			line3lt = "ADF L";
394			line3l = sprintf("%3.2f", getprop("/instrumentation/adf[0]/frequencies/selected-khz"));
395			line3rt = "ADF R";
396		}
397		if (display == "PERF_INIT") {
398			title = "PERF INIT";
399			line1lt = "GR WT";
400			line1rt = "CRZ ALT";
401			line1r = getprop("/autopilot/route-manager/cruise/altitude-ft");
402			line2lt = "FUEL";
403			line3lt = "ZFW";
404			line4lt = "RESERVES";
405			line4rt = "CRZ CG";
406			line5lt = "COST INDEX";
407			line5rt = "STEP SIZE";
408			line6l = "<INDEX";
409			line6r = "THRUST LIM>";
410			if (getprop("/sim/flight-model") == "jsb") {
411				line1l = sprintf("%3.1f", (getprop("/fdm/jsbsim/inertia/weight-lbs")/1000));
412				line2l = sprintf("%3.1f", (getprop("/fdm/jsbsim/propulsion/total-fuel-lbs")/1000));
413				line3l = sprintf("%3.1f", (getprop("/fdm/jsbsim/inertia/empty-weight-lbs")/1000));
414			}
415			elsif (getprop("/sim/flight-model") == "yasim") {
416				line1l = sprintf("%3.1f", (getprop("/yasim/gross-weight-lbs")/1000));
417				line2l = sprintf("%3.1f", (getprop("/consumables/fuel/total-fuel-lbs")/1000));
418
419				yasim_emptyweight = getprop("/yasim/gross-weight-lbs");
420				yasim_emptyweight -= getprop("/consumables/fuel/total-fuel-lbs");
421				yasim_weights = props.globals.getNode("/sim").getChildren("weight");
422				for (i = 0; i < size(yasim_weights); i += 1) {
423					yasim_emptyweight -= yasim_weights[i].getChild("weight-lb").getValue();
424				}
425
426				line3l = sprintf("%3.1f", yasim_emptyweight/1000);
427			}
428		}
429		if (display == "POS_INIT") {
430			title = "POS INIT";
431			line6l = "<INDEX";
432			line6r = "ROUTE>";
433		}
434		if (display == "POS_REF") {
435			title = "POS REF";
436			line1lt = "FMC POST";
437			line1l = getprop("/position/latitude-string")~" "~getprop("/position/longitude-string");
438			line1rt = "GS";
439			line1r = sprintf("%3.0f", getprop("/velocities/groundspeed-kt"));
440			line5l = "<PURGE";
441			line5r = "INHIBIT>";
442			line6l = "<INDEX";
443			line6r = "BRG/DIST>";
444		}
445		if (display == "RTE1_1") {
446			title = "RTE 1";
447			page = "1/2";
448			line1lt = "ORIGIN";
449			if (getprop("/autopilot/route-manager/departure/airport") != nil){
450				line1l = getprop("/autopilot/route-manager/departure/airport");
451			}
452			line1rt = "DEST";
453			if (getprop("/autopilot/route-manager/destination/airport") != nil){
454				line1r = getprop("/autopilot/route-manager/destination/airport");
455			}
456			line2lt = "RUNWAY";
457			if (getprop("/autopilot/route-manager/departure/runway") != nil){
458				line2l = getprop("/autopilot/route-manager/departure/runway");
459			}
460			line2rt = "FLT NO";
461			line3rt = "CO ROUTE";
462			line5l = "<RTE COPY";
463			line6l = "<RTE 2";
464			if (getprop("/autopilot/route-manager/active") == 1){
465				line6r = "PERF INIT>";
466				}
467			else {
468				line6r = "ACTIVATE>";
469				}
470		}
471		if (display == "RTE1_2") {
472			title = "RTE 1";
473			page = "2/2";
474			line1lt = "VIA";
475			line1rt = "TO";
476			if (getprop("/autopilot/route-manager/route/wp[1]/id") != nil){
477				line1r = getprop("/autopilot/route-manager/route/wp[1]/id");
478				}
479			if (getprop("/autopilot/route-manager/route/wp[2]/id") != nil){
480				line2r = getprop("/autopilot/route-manager/route/wp[2]/id");
481				}
482			if (getprop("/autopilot/route-manager/route/wp[3]/id") != nil){
483				line3r = getprop("/autopilot/route-manager/route/wp[3]/id");
484				}
485			if (getprop("/autopilot/route-manager/route/wp[4]/id") != nil){
486				line4r = getprop("/autopilot/route-manager/route/wp[4]/id");
487				}
488			if (getprop("/autopilot/route-manager/route/wp[5]/id") != nil){
489				line5r = getprop("/autopilot/route-manager/route/wp[5]/id");
490				}
491			line6l = "<RTE 2";
492			line6r = "ACTIVATE>";
493		}
494		if (display == "RTE1_ARR") {
495			if (getprop("/autopilot/route-manager/destination/airport") != nil){
496				title = getprop("/autopilot/route-manager/destination/airport")~" ARRIVALS";
497			}
498			else{
499				title = "ARRIVALS";
500			}
501			line1lt = "STARS";
502			line1rt = "APPROACHES";
503			if (getprop("/autopilot/route-manager/destination/runway") != nil){
504				line1r = getprop("/autopilot/route-manager/destination/runway");
505			}
506			line2lt = "TRANS";
507			line3rt = "RUNWAYS";
508			line6l = "<INDEX";
509			line6r = "ROUTE>";
510		}
511		if (display == "RTE1_DEP") {
512			if (getprop("/autopilot/route-manager/departure/airport") != nil){
513				title = getprop("/autopilot/route-manager/departure/airport")~" DEPARTURES";
514			}
515			else{
516				title = "DEPARTURES";
517			}
518			line1lt = "SIDS";
519			line1rt = "RUNWAYS";
520			if (getprop("/autopilot/route-manager/departure/runway") != nil){
521				line1r = getprop("/autopilot/route-manager/departure/runway");
522			}
523			line2lt = "TRANS";
524			line6l = "<ERASE";
525			line6r = "ROUTE>";
526		}
527		if (display == "RTE1_LEGS") {
528			if (getprop("/autopilot/route-manager/active") == 1){
529				title = "ACT RTE 1 LEGS";
530				}
531			else {
532				title = "RTE 1 LEGS";
533				}
534			if (getprop("/autopilot/route-manager/route/wp[1]/id") != nil){
535				line1lt = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[1]/leg-bearing-true-deg"));
536				line1l = getprop("/autopilot/route-manager/route/wp[1]/id");
537				line2ct = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[1]/leg-distance-nm"))~" NM";
538				line1r = sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[1]/altitude-ft"));
539				if (getprop("/autopilot/route-manager/route/wp[1]/speed-kts") != nil){
540					line4r = getprop("/autopilot/route-manager/route/wp[1]/speed-kts")~"/"~sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[1]/altitude-ft"));
541					}
542				}
543			if (getprop("/autopilot/route-manager/route/wp[2]/id") != nil){
544				if (getprop("/autopilot/route-manager/route/wp[2]/leg-bearing-true-deg") != nil){
545					line2lt = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[2]/leg-bearing-true-deg"));
546				}
547				line2l = getprop("/autopilot/route-manager/route/wp[2]/id");
548				if (getprop("/autopilot/route-manager/route/wp[2]/leg-distance-nm") != nil){
549					line3ct = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[2]/leg-distance-nm"))~" NM";
550				}
551				line2r = sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[2]/altitude-ft"));
552				if (getprop("/autopilot/route-manager/route/wp[2]/speed-kts") != nil){
553					line4r = getprop("/autopilot/route-manager/route/wp[2]/speed-kts")~"/"~sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[2]/altitude-ft"));
554					}
555				}
556			if (getprop("/autopilot/route-manager/route/wp[3]/id") != nil){
557				if (getprop("/autopilot/route-manager/route/wp[3]/leg-bearing-true-deg") != nil){
558					line3lt = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[3]/leg-bearing-true-deg"));
559				}
560				line3l = getprop("/autopilot/route-manager/route/wp[3]/id");
561				if (getprop("/autopilot/route-manager/route/wp[3]/leg-distance-nm") != nil){
562					line4ct = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[3]/leg-distance-nm"))~" NM";
563				}
564				line3r = sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[3]/altitude-ft"));
565				if (getprop("/autopilot/route-manager/route/wp[3]/speed-kts") != nil){
566					line3r = getprop("/autopilot/route-manager/route/wp[3]/speed-kts")~"/"~sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[3]/altitude-ft"));;
567					}
568				}
569			if (getprop("/autopilot/route-manager/route/wp[4]/id") != nil){
570				if (getprop("/autopilot/route-manager/route/wp[4]/leg-bearing-true-deg") != nil){
571					line4lt = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[4]/leg-bearing-true-deg"));
572				}
573				line4l = getprop("/autopilot/route-manager/route/wp[4]/id");
574				if (getprop("/autopilot/route-manager/route/wp[4]/leg-distance-nm") != nil){
575					line5ct = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[4]/leg-distance-nm"))~" NM";
576				}
577				line4r = sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[4]/altitude-ft"));
578				if (getprop("/autopilot/route-manager/route/wp[4]/speed-kts") != nil){
579					line4r = getprop("/autopilot/route-manager/route/wp[4]/speed-kts")~"/"~sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[4]/altitude-ft"));
580					}
581				}
582			if (getprop("/autopilot/route-manager/route/wp[5]/id") != nil){
583				if (getprop("/autopilot/route-manager/route/wp[5]/leg-bearing-true-deg") != nil){
584					line5lt = sprintf("%3.0f", getprop("/autopilot/route-manager/route/wp[5]/leg-bearing-true-deg"));
585				}
586				line5l = getprop("/autopilot/route-manager/route/wp[5]/id");
587				line5r = sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[5]/altitude-ft"));
588				if (getprop("/autopilot/route-manager/route/wp[5]/speed-kts") != nil){
589					line4r = getprop("/autopilot/route-manager/route/wp[5]/speed-kts")~"/"~sprintf("%5.0f", getprop("/autopilot/route-manager/route/wp[5]/altitude-ft"));
590					}
591				}
592			line6l = "<RTE 2 LEGS";
593			if (getprop("/autopilot/route-manager/active") == 1){
594				line6r = "RTE DATA>";
595				}
596			else{
597				line6r = "ACTIVATE>";
598				}
599		}
600		if (display == "THR_LIM") {
601			title = "THRUST LIM";
602			line1lt = "SEL";
603			line1ct = "OAT";
604			line1c = sprintf("%2.0f", getprop("/environment/temperature-degc"))~" �C";
605			line1rt = "TO 1 N1";
606			line2l = "<TO";
607			line2r = "CLB>";
608			line3lt = "TO 1";
609			line3c = "<SEL> <ARM>";
610			line3r = "CLB 1>";
611			line4lt = "TO 2";
612			line4r = "CLB 2>";
613			line6l = "<INDEX";
614			line6r = "TAKEOFF>";
615		}
616		if (display == "TO_REF") {
617			title = "TAKEOFF REF";
618			line1lt = "FLAP/ACCEL HT";
619			line1l = getprop("/instrumentation/fmc/to-flap");
620			line1rt = "REF V1";
621			if (getprop("/instrumentation/fmc/vspeeds/V1") != nil){
622				line1r = sprintf("%3.0f", getprop("/instrumentation/fmc/vspeeds/V1"));
623			}
624			line2lt = "E/O ACCEL HT";
625			line2rt = "REF VR";
626			if (getprop("/instrumentation/fmc/vspeeds/VR") != nil){
627				line2r = sprintf("%3.0f", getprop("/instrumentation/fmc/vspeeds/VR"));
628			}
629			line3lt = "THR REDUCTION";
630			line3rt = "REF V2";
631			if (getprop("/instrumentation/fmc/vspeeds/V2") != nil){
632				line3r = sprintf("%3.0f", getprop("/instrumentation/fmc/vspeeds/V2"));
633			}
634			line4lt = "WIND/SLOPE";
635			line4rt = "TRIM   CG%";
636			if (getprop("/instrumentation/fmc/cg") != nil and getprop("/instrumentation/fmc/stab-trim-units")){
637				line4r = sprintf("%1.1f", getprop("/instrumentation/fmc/stab-trim-units"))~"  "~sprintf("%2.1f", getprop("/instrumentation/fmc/cg"))~"%";
638			}
639			line5rt = "POS SHIFT";
640			line6l = "<INDEX";
641			line6r = "POS INIT>";
642		}
643
644		if (serviceable != 1){
645			title = "";		page = "";
646			line1l = "";	line2l = "";	line3l = "";	line4l = "";	line5l = "";	line6l = "";
647			line1lt = "";	line2lt = "";	line3lt = "";	line4lt = "";	line5lt = "";	line6lt = "";
648			line1c = "";	line2c = "";	line3c = "";	line4c = "";	line5c = "";	line6c = "";
649			line1ct = "";	line2ct = "";	line3ct = "";	line4ct = "";	line5ct = "";	line6ct = "";
650			line1r = "";	line2r = "";	line3r = "";	line4r = "";	line5r = "";	line6r = "";
651			line1rt = "";	line2rt = "";	line3rt = "";	line4rt = "";	line5rt = "";	line6rt = "";
652		}
653
654		setprop("/instrumentation/cdu/output/title",title);
655		setprop("/instrumentation/cdu/output/page",page);
656		setprop("/instrumentation/cdu/output/line1/left",line1l);
657		setprop("/instrumentation/cdu/output/line2/left",line2l);
658		setprop("/instrumentation/cdu/output/line3/left",line3l);
659		setprop("/instrumentation/cdu/output/line4/left",line4l);
660		setprop("/instrumentation/cdu/output/line5/left",line5l);
661		setprop("/instrumentation/cdu/output/line6/left",line6l);
662		setprop("/instrumentation/cdu/output/line1/left-title",line1lt);
663		setprop("/instrumentation/cdu/output/line2/left-title",line2lt);
664		setprop("/instrumentation/cdu/output/line3/left-title",line3lt);
665		setprop("/instrumentation/cdu/output/line4/left-title",line4lt);
666		setprop("/instrumentation/cdu/output/line5/left-title",line5lt);
667		setprop("/instrumentation/cdu/output/line6/left-title",line6lt);
668		setprop("/instrumentation/cdu/output/line1/center",line1c);
669		setprop("/instrumentation/cdu/output/line2/center",line2c);
670		setprop("/instrumentation/cdu/output/line3/center",line3c);
671		setprop("/instrumentation/cdu/output/line4/center",line4c);
672		setprop("/instrumentation/cdu/output/line5/center",line5c);
673		setprop("/instrumentation/cdu/output/line6/center",line6c);
674		setprop("/instrumentation/cdu/output/line1/center-title",line1ct);
675		setprop("/instrumentation/cdu/output/line2/center-title",line2ct);
676		setprop("/instrumentation/cdu/output/line3/center-title",line3ct);
677		setprop("/instrumentation/cdu/output/line4/center-title",line4ct);
678		setprop("/instrumentation/cdu/output/line5/center-title",line5ct);
679		setprop("/instrumentation/cdu/output/line6/center-title",line6ct);
680		setprop("/instrumentation/cdu/output/line1/right",line1r);
681		setprop("/instrumentation/cdu/output/line2/right",line2r);
682		setprop("/instrumentation/cdu/output/line3/right",line3r);
683		setprop("/instrumentation/cdu/output/line4/right",line4r);
684		setprop("/instrumentation/cdu/output/line5/right",line5r);
685		setprop("/instrumentation/cdu/output/line6/right",line6r);
686		setprop("/instrumentation/cdu/output/line1/right-title",line1rt);
687		setprop("/instrumentation/cdu/output/line2/right-title",line2rt);
688		setprop("/instrumentation/cdu/output/line3/right-title",line3rt);
689		setprop("/instrumentation/cdu/output/line4/right-title",line4rt);
690		setprop("/instrumentation/cdu/output/line5/right-title",line5rt);
691		setprop("/instrumentation/cdu/output/line6/right-title",line6rt);
692		settimer(cdu,0.2);
693    }
694_setlistener("/sim/signals/fdm-initialized", cdu);
695