АБСУ: не отключать АТ при перемещении отключенного МЭТ.

parent d227c8c0
......@@ -3,6 +3,7 @@
# This class handles some FlightGear initializations and provides
# the tools for scripting states or procedures in Nasal.
# FIXME Replace getprop and setprop with nodes!
# TODO When animating the cockpit or adding switch sounds, simply
# TODO replace setprop() with a func that checks if the property will
......@@ -106,7 +107,8 @@ TrimDo = func () {
# @param eng Engine, 0..4.
# @param throttle Throttle, 0..90 degrees.
Throttle = func (eng, throttle) {
setprop("/controls/engines/engine[" ~ eng ~ "]/throttle", (throttle / 90.0));
var diff = (throttle / 90.0) - getprop("/controls/engines/engine[" ~ eng ~ "]/throttle");
controls.incThrottle(diff, 0.0);
}
# @brief Set throttle for all engines.
......@@ -1075,6 +1077,33 @@ PreTaxi = func {
# FG control bindings
# arg[0] is the throttle increment
# arg[1] is unused
controls.incThrottle = func() {
var down = (arg[0] < -0.001 ? 1 : 0);
var up = (arg[0] > 0.001 ? 1 : 0);
for(var ii = 0; ii < 4; ii += 1){
if(getprop("/sim/input/selected/engine[" ~ ii ~ "]")){
var val = getprop("/controls/engines/engine[" ~ ii ~ "]/throttle") + arg[0];
setprop("/controls/engines/engine[" ~ ii ~ "]/throttle", val < 0.0 ? 0.0 : val > 1.0 ? 1.0 : val);
setprop("/fdm/jsbsim/fcs/throttle-moving-up[" ~ ii ~ "]", up);
setprop("/fdm/jsbsim/fcs/throttle-moving-down[" ~ ii ~ "]", down);
}
}
settimer(func{
for(var ii = 0; ii < 4; ii += 1){
setprop("/fdm/jsbsim/fcs/throttle-moving-up[" ~ ii ~ "]", 0);
setprop("/fdm/jsbsim/fcs/throttle-moving-down[" ~ ii ~ "]", 0);
}
}, 0.5);
}
controls.throttleMouse = func {
if(!getprop("/devices/status/mice/mouse[0]/button[1]")) return;
var delta = cmdarg().getNode("offset").getValue() * -4;
controls.incThrottle(delta, 0.0);
}
controls.ptt = func(ptt){
if(getprop("/sim/ptt-autoselect")){
if(ptt){
......
......@@ -771,17 +771,7 @@
controls.incThrottle(0.01, 1.0)
</script>
</binding>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/simulation/throttle-moving-up</property>
<value type="double">1.0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/simulation/throttle-moving-up</property>
<value type="double">0.0</value>
</binding>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/fcs/NPK/panel/AT/pot/speed</property>
......@@ -795,17 +785,11 @@
<property>/fdm/jsbsim/fcs/NPK/panel/AT/pot/speed</property>
<value type="double">1.0</value>
</binding>
<!-- FGBUG https://sourceforge.net/p/flightgear/codetickets/2085/ <mod-up> does not work when going between modifiers without releasing the key. -->
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/simulation/throttle-moving-up</property>
<value type="double">0.0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/fcs/NPK/panel/AT/pot/speed</property>
<value type="double">0.0</value>
<value type="double">0</value>
</binding>
</mod-up>
</mod-ctrl>
......@@ -821,17 +805,7 @@
controls.incThrottle(-0.01, -1.0)
</script>
</binding>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/simulation/throttle-moving-down</property>
<value type="double">1.0</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/simulation/throttle-moving-down</property>
<value type="double">0.0</value>
</binding>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/fcs/NPK/panel/AT/pot/speed</property>
......@@ -843,19 +817,13 @@
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/fcs/NPK/panel/AT/pot/speed</property>
<value type="double">-1.0</value>
</binding>
<!-- FGBUG https://sourceforge.net/p/flightgear/codetickets/2085/ <mod-up> does not work when going between modifiers without releasing the key. -->
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/simulation/throttle-moving-down</property>
<value type="double">0.0</value>
<value type="double">-1</value>
</binding>
<mod-up>
<binding>
<command>property-assign</command>
<property>/fdm/jsbsim/fcs/NPK/panel/AT/pot/speed</property>
<value type="double">0.0</value>
<value type="double">0</value>
</binding>
</mod-up>
</mod-ctrl>
......
......@@ -17,12 +17,17 @@
<property value="-1.0">simulation/settings/AT-min-diff-deg</property>
<property value="1.0">simulation/settings/AT-max-diff-deg</property>
<!--
Write a program that sets these to "1" when pilot's force on at
least at least one throttle lever exceeds 2.0 kg in respective
direction, and "0" at any other times.
-->
<property>simulation/throttle-moving-up</property>
<property>simulation/throttle-moving-down</property>
Switches for pilot's force. See Tu-144.nas controls.incThrottle
override on how these should be set.
-->
<property>fcs/throttle-moving-up[0]</property>
<property>fcs/throttle-moving-down[0]</property>
<property>fcs/throttle-moving-up[1]</property>
<property>fcs/throttle-moving-down[1]</property>
<property>fcs/throttle-moving-up[2]</property>
<property>fcs/throttle-moving-down[2]</property>
<property>fcs/throttle-moving-up[3]</property>
<property>fcs/throttle-moving-down[3]</property>
<!-- [p. 7] -->
......@@ -210,22 +215,72 @@
<switch name="&U;/status/force-disengage-up">
<default value="0"/>
<test logic="OR" value="1">
simulation/throttle-moving-up NE 0
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[0] EQ 0
fcs/throttle-moving-up[0] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[0] EQ 0
&U;/func/pilot-diff-deg[0] GT simulation/settings/AT-max-diff-deg
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[1] EQ 0
fcs/throttle-moving-up[1] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[1] EQ 0
&U;/func/pilot-diff-deg[1] GT simulation/settings/AT-max-diff-deg
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[2] EQ 0
fcs/throttle-moving-up[2] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[2] EQ 0
&U;/func/pilot-diff-deg[2] GT simulation/settings/AT-max-diff-deg
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[3] EQ 0
fcs/throttle-moving-up[3] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[3] EQ 0
&U;/func/pilot-diff-deg[3] GT simulation/settings/AT-max-diff-deg
</test>
</switch>
<switch name="&U;/status/force-disengage">
<default value="0"/>
<test logic="OR" value="1">
simulation/throttle-moving-down NE 0
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[0] EQ 0
fcs/throttle-moving-down[0] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[0] EQ 0
&U;/func/pilot-diff-deg[0] LT simulation/settings/AT-min-diff-deg
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[1] EQ 0
fcs/throttle-moving-down[1] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[1] EQ 0
&U;/func/pilot-diff-deg[1] LT simulation/settings/AT-min-diff-deg
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[2] EQ 0
fcs/throttle-moving-down[2] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[2] EQ 0
&U;/func/pilot-diff-deg[2] LT simulation/settings/AT-min-diff-deg
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[3] EQ 0
fcs/throttle-moving-down[3] NE 0
</test>
<test logic="AND" value="1">
&NPK;/panel/AT/button/disconnect[3] EQ 0
&U;/func/pilot-diff-deg[3] LT simulation/settings/AT-min-diff-deg
</test>
<test logic="AND" value="1">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment