cruise level can be inserted into MCDU, rewrite MCDU button system

This commit is contained in:
Joshua Davidson 2017-05-18 14:41:33 -04:00
parent 650d9fdb3f
commit 218934a566
7 changed files with 224 additions and 52 deletions

View file

@ -33,7 +33,7 @@
<alignment>center-center</alignment>
<axis-alignment>yz-plane</axis-alignment>
<type type="string">text-value</type>
<format type="string">INIT</format>
<format type="string">INIT &lt;--&gt;</format>
<truncate type="bool">false</truncate>
<font type="string">BoeingCDU-Large.ttf</font>
<property>autopilot/serviceable</property>
@ -480,7 +480,7 @@
<alignment>left-center</alignment>
<axis-alignment>yz-plane</axis-alignment>
<type type="string">text-value</type>
<format type="string">CRZ FL/TEMP.</format>
<format type="string">CRZ FL/TEMP</format>
<truncate type="bool">false</truncate>
<font type="string">BoeingCDU-Large.ttf</font>
<property>autopilot/serviceable</property>
@ -516,6 +516,44 @@
<height type="int">64</height>
</font-resolution>
</text>
<text>
<name>crzfltemp3</name>
<offsets>
<x-m>-0.001</x-m>
<y-m>-0.045</y-m>
<z-m>0.0170</z-m>
</offsets>
<alignment>left-center</alignment>
<axis-alignment>yz-plane</axis-alignment>
<type type="string">text-value</type>
<format type="string">FL%s/---</format>
<truncate type="bool">false</truncate>
<font type="string">BoeingCDU-Large.ttf</font>
<property>/FMGC/internal/cruise-fl</property>
<draw-text type="bool">true</draw-text>
<draw-alignment type="bool">false</draw-alignment>
<draw-boundingbox type="bool">false</draw-boundingbox>
<character-size>0.0050</character-size>
<font-resolution>
<width type="int">64</width>
<height type="int">64</height>
</font-resolution>
</text>
<animation>
<type>select</type>
<object-name>crzfltemp2</object-name>
<condition>
<not><property>/FMGC/internal/cruise-lvl-set</property></not>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>crzfltemp3</object-name>
<condition>
<property>/FMGC/internal/cruise-lvl-set</property>
</condition>
</animation>
<text>
<name>LONG</name>
@ -763,6 +801,7 @@
<object-name>tropovalue</object-name>
<object-name>LONG-val</object-name>
<object-name>LAT-val</object-name>
<object-name>crzfltemp3</object-name>
<diffuse>
<red>0</red>
<green>0.5</green>

View file

@ -201,7 +201,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.latbutton("1");</script>
<script>mcdu1.lskbutton("1");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -219,7 +219,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.latbutton("2");</script>
<script>mcdu1.lskbutton("2");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -237,7 +237,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.latbutton("3");</script>
<script>mcdu1.lskbutton("3");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -255,7 +255,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.latbutton("4");</script>
<script>mcdu1.lskbutton("4");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -273,7 +273,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.latbutton("5");</script>
<script>mcdu1.lskbutton("5");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -291,7 +291,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.latbutton("6");</script>
<script>mcdu1.lskbutton("6");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -310,7 +310,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.vertbutton("1");</script>
<script>mcdu1.rskbutton("1");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -328,7 +328,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.vertbutton("2");</script>
<script>mcdu1.rskbutton("2");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -346,7 +346,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.vertbutton("3");</script>
<script>mcdu1.rskbutton("3");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -364,7 +364,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.vertbutton("4");</script>
<script>mcdu1.rskbutton("4");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -382,7 +382,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.vertbutton("5");</script>
<script>mcdu1.rskbutton("5");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -400,7 +400,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu1.vertbutton("6");</script>
<script>mcdu1.rskbutton("6");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>

View file

@ -33,7 +33,7 @@
<alignment>center-center</alignment>
<axis-alignment>yz-plane</axis-alignment>
<type type="string">text-value</type>
<format type="string">INIT</format>
<format type="string">INIT &lt;--&gt;</format>
<truncate type="bool">false</truncate>
<font type="string">BoeingCDU-Large.ttf</font>
<property>autopilot/serviceable</property>
@ -480,7 +480,7 @@
<alignment>left-center</alignment>
<axis-alignment>yz-plane</axis-alignment>
<type type="string">text-value</type>
<format type="string">CRZ FL/TEMP.</format>
<format type="string">CRZ FL/TEMP</format>
<truncate type="bool">false</truncate>
<font type="string">BoeingCDU-Large.ttf</font>
<property>autopilot/serviceable</property>
@ -516,6 +516,44 @@
<height type="int">64</height>
</font-resolution>
</text>
<text>
<name>crzfltemp3</name>
<offsets>
<x-m>-0.001</x-m>
<y-m>-0.045</y-m>
<z-m>0.0170</z-m>
</offsets>
<alignment>left-center</alignment>
<axis-alignment>yz-plane</axis-alignment>
<type type="string">text-value</type>
<format type="string">FL%s/---</format>
<truncate type="bool">false</truncate>
<font type="string">BoeingCDU-Large.ttf</font>
<property>/FMGC/internal/cruise-fl</property>
<draw-text type="bool">true</draw-text>
<draw-alignment type="bool">false</draw-alignment>
<draw-boundingbox type="bool">false</draw-boundingbox>
<character-size>0.0050</character-size>
<font-resolution>
<width type="int">64</width>
<height type="int">64</height>
</font-resolution>
</text>
<animation>
<type>select</type>
<object-name>crzfltemp2</object-name>
<condition>
<not><property>/FMGC/internal/cruise-lvl-set</property></not>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>crzfltemp3</object-name>
<condition>
<property>/FMGC/internal/cruise-lvl-set</property>
</condition>
</animation>
<text>
<name>LONG</name>
@ -763,6 +801,7 @@
<object-name>tropovalue</object-name>
<object-name>LONG-val</object-name>
<object-name>LAT-val</object-name>
<object-name>crzfltemp3</object-name>
<diffuse>
<red>0</red>
<green>0.5</green>

View file

@ -201,7 +201,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.latbutton("1");</script>
<script>mcdu2.lskbutton("1");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -219,7 +219,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.latbutton("2");</script>
<script>mcdu2.lskbutton("2");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -237,7 +237,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.latbutton("3");</script>
<script>mcdu2.lskbutton("3");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -255,7 +255,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.latbutton("4");</script>
<script>mcdu2.lskbutton("4");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -273,7 +273,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.latbutton("5");</script>
<script>mcdu2.lskbutton("5");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -291,7 +291,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.latbutton("6");</script>
<script>mcdu2.lskbutton("6");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -310,7 +310,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.vertbutton("1");</script>
<script>mcdu2.rskbutton("1");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -328,7 +328,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.vertbutton("2");</script>
<script>mcdu2.rskbutton("2");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -346,7 +346,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.vertbutton("3");</script>
<script>mcdu2.rskbutton("3");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -364,7 +364,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.vertbutton("4");</script>
<script>mcdu2.rskbutton("4");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -382,7 +382,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.vertbutton("5");</script>
<script>mcdu2.rskbutton("5");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>
@ -400,7 +400,7 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu2.vertbutton("6");</script>
<script>mcdu2.rskbutton("6");</script>
<condition>
<greater-than-equals>
<property>/systems/electrical/bus/ac1</property>

View file

@ -10,12 +10,13 @@ setprop("/position/gear-agl-ft", 0);
var FMGCinit = func {
setprop("/FMGC/status/to-state", 0);
setprop("/FMGC/status/phase", "0"); # 0 is preflight 1 takeoff 2 climb 3 cruise 4 descent 5 approach 6 go around 7 done
setprop("/FMGC/internal/cruise-fl", 10000);
setprop("/FMGC/internal/cruise-ft", 10000);
setprop("/FMGC/internal/cruise-fl", 100);
setprop("/FMGC/internal/tropo", 36090);
setprop("/FMGC/internal/cost", " ");
setprop("/FMGC/internal/greendot-kts", 0);
phasecheck.start();
greendot.start();
greendott.start();
}
#############
@ -58,7 +59,7 @@ var phasecheck = maketimer(0.2, func {
var mode = getprop("/modes/pfd/fma/pitch-mode");
var gs = getprop("/velocities/groundspeed-kt");
var alt = getprop("/instrumentation/altimeter/indicated-altitude-ft");
var cruisefl = getprop("/FMGC/internal/cruise-fl");
var cruisefl = getprop("/FMGC/internal/cruise-ft");
var newcruise = getprop("/it-autoflight/internal/alt");
var phase = getprop("/FMGC/status/phase");
var state1 = getprop("/systems/thrust/state1");
@ -91,13 +92,18 @@ var phasecheck = maketimer(0.2, func {
if ((phase == "6") and ((vertmode == "G/A CLB") or (vertmode == "SPD CLB") or (vertmode == "CLB") or ((vertmode == "V/S") and (targetvs > 0)) or ((vertmode == "FPA") and (targetfpa > 0))) and (alt <= targetalt)) {
setprop("/FMGC/status/phase", "2"); # going to CLIMB mode from GA
}
if ((wowl and wowr) and (gs < 20)) { # below twenty knots. In future make a timer to ensure that it goes to DONE 30 sec after landing.
if ((wowl and wowr) and (gs < 20) and (phase == "5")) { # below twenty knots.
setprop("/FMGC/status/phase", "7");
FMGCinit(); # reset. Eventually make it reset only when INIT / PERF page are accessed
settimer(func {
itaf.ap_init();
FMGCinit();
mcdu1.MCDU_reset();
mcdu2.MCDU_reset();
}, 30);
}
});
var greendot = maketimer(0.1, func {
var greendott = maketimer(0.1, func {
var gwlb = getprop("fdm/jsbsim/inertia/weight-lbs");
var factor = 0.45359237;
var kg = (gwlb * factor);

View file

@ -11,10 +11,11 @@ var MCDU_reset = func {
setprop("/MCDU[0]/page", "STATUS");
setprop("/MCDU[0]/cost-index", 0);
setprop("/MCDU[0]/flight-num", 0);
setprop("/MCDU[0]/scratchpad", " ");
setprop("/MCDU[0]/scratchpad", "");
setprop("/FMGC/internal/cruise-lvl-set", 0);
}
var latbutton = func(btn) {
var lskbutton = func(btn) {
if (btn == "4") {
if (getprop("/MCDU[0]/page") == "DATA") {
setprop("/MCDU[0]/page", "NONE");
@ -22,32 +23,66 @@ var latbutton = func(btn) {
setprop("/MCDU[0]/page", "STATUS");
}, 0.2);
}
} else if (btn == "6") {
if (getprop("/MCDU[0]/page") == "INITA") {
initInputA("L6");
}
}
}
var vertbutton = func(btn) {
var initInputA = func(key) {
var scratchpad = getprop("/MCDU[0]/scratchpad");
if (key == "L6") {
if (scratchpad == "CLR") {
screenFlash(0.2);
setprop("/FMGC/internal/cruise-ft", 10000);
setprop("/FMGC/internal/cruise-fl", 100);
setprop("/FMGC/internal/cruise-lvl-set", 0);
setprop("/MCDU[0]/scratchpad", "");
} else {
var crz = int(scratchpad);
var crzs = size(scratchpad);
print(crz);
print(crzs);
if (crzs >= 1 and crzs <= 3) {
screenFlash(0.2);
setprop("/FMGC/internal/cruise-ft", crz * 100);
setprop("/FMGC/internal/cruise-fl", crz);
setprop("/FMGC/internal/cruise-lvl-set", 1);
setprop("/MCDU[0]/scratchpad", "");
} else {
screenFlash(0.2);
setprop("/MCDU[0]/scratchpad", "NOT ALLOWED");
}
}
}
}
var rskbutton = func(btn) {
# LOL Nothing here :D
}
var arrowbutton = func(btn) {
if (btn == "left") {
setprop("/MCDU[0]/page", "NONE");
if (getprop("/MCDU[0]/page") == "DATA") {
setprop("/MCDU[0]/page", "NONE");
settimer(func {
setprop("/MCDU[0]/page", "DATA2");
}, 0.2);
} else if (getprop("/MCDU[0]/page") == "DATA2") {
setprop("/MCDU[0]/page", "NONE");
settimer(func {
setprop("/MCDU[0]/page", "DATA");
}, 0.2);
}
} else if (btn == "right") {
setprop("/MCDU[0]/page", "NONE");
if (getprop("/MCDU[0]/page") == "DATA") {
setprop("/MCDU[0]/page", "NONE");
settimer(func {
setprop("/MCDU[0]/page", "DATA2");
}, 0.2);
} else if (getprop("/MCDU[0]/page") == "DATA2") {
setprop("/MCDU[0]/page", "NONE");
settimer(func {
setprop("/MCDU[0]/page", "DATA");
}, 0.2);
@ -137,13 +172,15 @@ var button = func(btn) {
} else if (btn == "SLASH") {
setprop("/MCDU[0]/scratchpad", scratchpad ~ "/");
} else if (btn == "SP") {
setprop("/MCDU[0]/scratchpad", scratchpad ~ " "); # this button adds a space
setprop("/MCDU[0]/scratchpad", scratchpad ~ " ");
} else if (btn == "CLR") {
var scratchpad = getprop("/MCDU[0]/scratchpad");
if (scratchpad == " ") {
if (size(scratchpad) == 0) {
setprop("/MCDU[0]/scratchpad", "CLR");
} else if (scratchpad == "CLR") {
setprop("/MCDU[0]/scratchpad", " ");
setprop("/MCDU[0]/scratchpad", "");
} else if (scratchpad == "NOT ALLOWED") {
setprop("/MCDU[0]/scratchpad", "");
} else if (size(scratchpad) > 0) {
setprop("/MCDU[0]/scratchpad", left(scratchpad, size(scratchpad)-1));
}
@ -170,4 +207,12 @@ var button = func(btn) {
} else if (btn == "DOT") {
setprop("/MCDU[0]/scratchpad", scratchpad ~ ".");
}
}
}
var screenFlash = func(time) {
var page = getprop("/MCDU[0]/page");
setprop("/MCDU[0]/page", "NONE");
settimer(func {
setprop("/MCDU[0]/page", page);
}, time);
}

View file

@ -11,10 +11,11 @@ var MCDU_reset = func {
setprop("/MCDU[1]/page", "STATUS");
setprop("/MCDU[1]/cost-index", 0);
setprop("/MCDU[1]/flight-num", 0);
setprop("/MCDU[1]/scratchpad", " ");
setprop("/MCDU[1]/scratchpad", "");
setprop("/FMGC/internal/cruise-lvl-set", 0);
}
var latbutton = func(btn) {
var lskbutton = func(btn) {
if (btn == "4") {
if (getprop("/MCDU[1]/page") == "DATA") {
setprop("/MCDU[1]/page", "NONE");
@ -22,32 +23,64 @@ var latbutton = func(btn) {
setprop("/MCDU[1]/page", "STATUS");
}, 0.2);
}
} else if (btn == "6") {
if (getprop("/MCDU[1]/page") == "INITA") {
initInputA("L6");
}
}
}
var vertbutton = func(btn) {
var initInputA = func(key) {
var scratchpad = getprop("/MCDU[1]/scratchpad");
if (key == "L6") {
if (scratchpad == "CLR") {
screenFlash(0.2);
setprop("/FMGC/internal/cruise-ft", 10000);
setprop("/FMGC/internal/cruise-fl", 100);
setprop("/FMGC/internal/cruise-lvl-set", 0);
setprop("/MCDU[1]/scratchpad", "");
} else {
var crz = int(scratchpad);
var crzs = size(scratchpad);
if (crzs >= 1 and crzs <= 3) {
screenFlash(0.2);
setprop("/FMGC/internal/cruise-ft", crz * 100);
setprop("/FMGC/internal/cruise-fl", crz);
setprop("/FMGC/internal/cruise-lvl-set", 1);
setprop("/MCDU[1]/scratchpad", "");
} else {
screenFlash(0.2);
setprop("/MCDU[1]/scratchpad", "NOT ALLOWED");
}
}
}
}
var rskbutton = func(btn) {
# LOL Nothing here :D
}
var arrowbutton = func(btn) {
if (btn == "left") {
setprop("/MCDU[1]/page", "NONE");
if (getprop("/MCDU[1]/page") == "DATA") {
setprop("/MCDU[1]/page", "NONE");
settimer(func {
setprop("/MCDU[1]/page", "DATA2");
}, 0.2);
} else if (getprop("/MCDU[1]/page") == "DATA2") {
setprop("/MCDU[1]/page", "NONE");
settimer(func {
setprop("/MCDU[1]/page", "DATA");
}, 0.2);
}
} else if (btn == "right") {
setprop("/MCDU[1]/page", "NONE");
if (getprop("/MCDU[1]/page") == "DATA") {
setprop("/MCDU[1]/page", "NONE");
settimer(func {
setprop("/MCDU[1]/page", "DATA2");
}, 0.2);
} else if (getprop("/MCDU[1]/page") == "DATA2") {
setprop("/MCDU[1]/page", "NONE");
settimer(func {
setprop("/MCDU[1]/page", "DATA");
}, 0.2);
@ -137,13 +170,15 @@ var button = func(btn) {
} else if (btn == "SLASH") {
setprop("/MCDU[1]/scratchpad", scratchpad ~ "/");
} else if (btn == "SP") {
setprop("/MCDU[1]/scratchpad", scratchpad ~ " "); # this button adds a space
setprop("/MCDU[1]/scratchpad", scratchpad ~ " ");
} else if (btn == "CLR") {
var scratchpad = getprop("/MCDU[1]/scratchpad");
if (scratchpad == " ") {
if (size(scratchpad) == 0) {
setprop("/MCDU[1]/scratchpad", "CLR");
} else if (scratchpad == "CLR") {
setprop("/MCDU[1]/scratchpad", " ");
setprop("/MCDU[1]/scratchpad", "");
} else if (scratchpad == "NOT ALLOWED") {
setprop("/MCDU[1]/scratchpad", "");
} else if (size(scratchpad) > 0) {
setprop("/MCDU[1]/scratchpad", left(scratchpad, size(scratchpad)-1));
}
@ -170,4 +205,12 @@ var button = func(btn) {
} else if (btn == "DOT") {
setprop("/MCDU[1]/scratchpad", scratchpad ~ ".");
}
}
}
var screenFlash = func(time) {
var page = getprop("/MCDU[1]/page");
setprop("/MCDU[1]/page", "NONE");
settimer(func {
setprop("/MCDU[1]/page", page);
}, time);
}