1
0
Fork 0

Revision of FBW degradation logic, rudder trim implemented to spec. Todo -- rudder trim should affect RTLU. Separate yaw law -- normal, alternate, and mechanical.

This commit is contained in:
legoboyvdlp R 2020-07-16 19:50:01 +01:00
parent 3e93cc7726
commit a28879577c
9 changed files with 224 additions and 99 deletions

View file

@ -614,6 +614,8 @@
<alpha-hld type="bool">0</alpha-hld>
<degrade-law type="int">0</degrade-law>
<law type="int">0</law>
<degrade-yaw-law type="int">0</degrade-yaw-law>
<yaw-law type="int">0</yaw-law>
<roll-lim type="string">33</roll-lim>
<roll-back type="bool">0</roll-back>
<override type="bool">0</override>
@ -910,7 +912,7 @@
<!-- Smoking is bad :P -->
<no-smoking-sign type="double">0.5</no-smoking-sign>
<seatbelt-sign type="double">0.0</seatbelt-sign>
<annun-test>0</annun-test>
<annun-test type="int">0</annun-test>
<qnh-knb>100000</qnh-knb>
<strobe type="double">0.0</strobe>
<beacon type="bool">0</beacon>

View file

@ -53,6 +53,8 @@
<script>
setprop("it-fbw/degrade-law", 0);
setprop("it-fbw/law", 0);
setprop("it-fbw/degrade-yaw-law", 0);
setprop("it-fbw/yaw-law", 0);
gui.popupTip("Fly By Wire switched to NORMAL law!");
</script>
</binding>
@ -69,6 +71,8 @@
<script>
setprop("it-fbw/degrade-law", 1);
setprop("it-fbw/law", 1);
setprop("it-fbw/degrade-yaw-law", 1);
setprop("it-fbw/yaw-law", 1);
gui.popupTip("Fly By Wire switched to ALTERNATE law!");
</script>
</binding>
@ -85,6 +89,8 @@
<script>
setprop("it-fbw/degrade-law", 2);
setprop("it-fbw/law", 2);
setprop("it-fbw/degrade-yaw-law", 2);
setprop("it-fbw/yaw-law", 2);
gui.popupTip("Fly By Wire switched to DIRECT law!");
</script>
</binding>
@ -101,6 +107,8 @@
<script>
setprop("it-fbw/degrade-law", 3);
setprop("it-fbw/law", 3);
setprop("it-fbw/degrade-yaw-law", 2);
setprop("it-fbw/yaw-law", 2);
gui.popupTip("Fly By Wire switched to MECHANICAL BACKUP law!");
</script>
</binding>

View file

@ -1157,16 +1157,22 @@
<repeatable>true</repeatable>
<binding>
<condition>
<or>
<greater-than-equals>
<property>systems/electrical/bus/dc-ess</property>
<value>25</value>
</greater-than-equals>
<greater-than-equals>
<property>systems/electrical/bus/dc-2</property>
<value>25</value>
</greater-than-equals>
</or>
<and>
<not>
<property>/it-autoflight/output/ap1</property>
<property>/it-autoflight/output/ap2</property>
</not>
<or>
<greater-than-equals>
<property>systems/electrical/bus/dc-ess</property>
<value>25</value>
</greater-than-equals>
<greater-than-equals>
<property>systems/electrical/bus/dc-2</property>
<value>25</value>
</greater-than-equals>
</or>
</and>
</condition>
<command>nasal</command>
<script>
@ -1235,16 +1241,22 @@
<repeatable>false</repeatable>
<binding>
<condition>
<or>
<greater-than-equals>
<property>systems/electrical/bus/dc-ess</property>
<value>25</value>
</greater-than-equals>
<greater-than-equals>
<property>systems/electrical/bus/dc-2</property>
<value>25</value>
</greater-than-equals>
</or>
<and>
<not>
<property>/it-autoflight/output/ap1</property>
<property>/it-autoflight/output/ap2</property>
</not>
<or>
<greater-than-equals>
<property>systems/electrical/bus/dc-ess</property>
<value>25</value>
</greater-than-equals>
<greater-than-equals>
<property>systems/electrical/bus/dc-2</property>
<value>25</value>
</greater-than-equals>
</or>
</and>
</condition>
<command>nasal</command>
<script>

View file

@ -21,10 +21,14 @@ var ail = 0;
var roll = 0;
var rollback = 0;
var law = 0;
var lawyaw = 0;
var FBW = {
apOff: 0,
degradeLaw: props.globals.getNode("/it-fbw/degrade-law"),
degradeYawLaw: props.globals.getNode("/it-fbw/degrade-yaw-law"),
activeLaw: props.globals.getNode("/it-fbw/law"),
activeYawLaw: props.globals.getNode("/it-fbw/yaw-law"),
override: props.globals.getNode("/it-fbw/override"),
rollBack: props.globals.getNode("/it-fbw/roll-back"),
rollLim: props.globals.getNode("/it-fbw/roll-lim"),
@ -105,6 +109,7 @@ var FBW = {
me.degradeLaw.setValue(0);
me.activeLaw.setValue(0);
me.override.setValue(0);
me.apOff = 0;
if (!updatet.isRunning) {
updatet.start();
@ -133,6 +138,7 @@ var update_loop = func {
fac1 = FBW.Computers.fac1.getBoolValue();
fac2 = FBW.Computers.fac2.getBoolValue();
law = FBW.activeLaw.getValue();
lawyaw = FBW.activeYawLaw.getValue();
# Degrade logic, all failures which degrade FBW need to go here. -JD
blue = systems.HYD.Psi.blue.getValue();
@ -140,30 +146,70 @@ var update_loop = func {
yellow = systems.HYD.Psi.yellow.getValue();
if (!pts.Gear.wow[1].getBoolValue() and !pts.Gear.wow[2].getBoolValue()) {
if (!elac1 and !elac2) {
if (lawyaw == 0) {
FBW.degradeYawLaw.setValue(1);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
FBW.apOff = 1;
}
}
if ((!elac1 and elac2 and ((green < 1500 and yellow >= 1500) or (green >= 1500 and yellow < 1500))) or (!elac2 and elac1 and blue < 1500)) {
if (lawyaw == 0) {
FBW.degradeYawLaw.setValue(1);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
FBW.apOff = 1;
}
}
if (!sec1 and !sec2 and !sec3) {
if (lawyaw == 0) {
FBW.degradeYawLaw.setValue(1);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
fcu.apOff("hard", 0);
fcu.athrOff("hard");
}
}
if (systems.ELEC.EmerElec.getBoolValue()) {
if (lawyaw == 0 or lawyaw == 1) {
FBW.degradeYawLaw.setValue(2);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
fcu.apOff("hard", 0);
fcu.athrOff("hard");
FBW.apOff = 1;
}
}
if ((blue >= 1500 and green < 1500 and yellow < 1500) or (blue < 1500 and green < 1500 and yellow >= 1500)) {
if (law == 0 or law == 1) {
FBW.degradeLaw.setValue(2);
fcu.apOff("hard", 0);
fcu.athrOff("hard");
if (blue >= 1500 and green < 1500 and yellow < 1500) {
if (lawyaw == 0 or lawyaw == 1) {
FBW.degradeYawLaw.setValue(2);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
FBW.apOff = 1;
}
}
if (systems.ELEC.Bus.dcEss.getValue() < 25 and systems.ELEC.Bus.dc2.getValue() < 25) {
if (blue < 1500 and green < 1500 and yellow >= 1500) {
if (lawyaw == 0) {
FBW.degradeYawLaw.setValue(1);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
FBW.apOff = 1;
}
}
if (!fac1 and !fac2 ) {
if (lawyaw == 0 or lawyaw == 1) {
FBW.degradeYawLaw.setValue(2);
}
if (law == 0) {
FBW.degradeLaw.setValue(1);
FBW.apOff = 1;
}
}
if (!elac1 and !elac2 and !sec1 and !sec2 and !sec3 and !fac1 and !fac2) {
FBW.degradeLaw.setValue(3);
fcu.apOff("hard", 0);
fcu.athrOff("hard");
FBW.apOff = 1;
}
}
@ -255,9 +301,25 @@ var fbw_loop = func {
FBW.activeLaw.setValue(3);
}
}
active = FBW.activeYawLaw.getValue();
degrade = FBW.degradeYawLaw.getValue();
if (degrade == 0) {
if (active != 0) {
FBW.activeYawLaw.setValue(0);
}
} else if (degrade == 1) {
if (active != 1) {
FBW.activeYawLaw.setValue(1);
}
} else if (degrade == 2) {
if (active != 2) {
FBW.activeYawLaw.setValue(2);
}
}
}
if (FBW.activeLaw.getValue() != 0) {
if (FBW.apOff) {
if (fmgc.Input.ap1.getBoolValue() or fmgc.Input.ap2.getBoolValue()) {
fcu.apOff("hard", 0);
fcu.athrOff("hard");

View file

@ -103,6 +103,7 @@ var FCUController = {
if (!ap1.getBoolValue()) {
ap1Input.setValue(1);
ecam.apWarnNode.setValue(0);
pts.Controls.Flight.rudderTrim.setValue(0);
} else {
apOff("hard", 1);
}
@ -112,6 +113,7 @@ var FCUController = {
if (me.FCUworking and fbw.FBW.activeLaw.getValue() == 0) {
if (!ap2.getBoolValue()) {
ap2Input.setValue(1);
pts.Controls.Flight.rudderTrim.setValue(0);
} else {
apOff("hard", 2);
}

View file

@ -34,6 +34,7 @@ var Controls = {
flapsPos: props.globals.getNode("/controls/flight/flaps-pos"),
speedbrake: props.globals.getNode("/controls/flight/speedbrake"),
speedbrakeArm: props.globals.getNode("/controls/flight/speedbrake-arm"),
rudderTrim: props.globals.getNode("/controls/flight/rudder-trim"),
},
Gear: {
gearDown: props.globals.getNode("/controls/gear/gear-down"),

View file

@ -24,7 +24,7 @@ setlistener("sim/signals/fdm-initialized", func {
props.globals.initNode("instrumentation/chrono[0]/chr-et-min",0,"INT");
props.globals.initNode("instrumentation/chrono[0]/chr-et-sec",0,"INT");
props.globals.initNode("controls/flight/rudder-trim-display",0,"STRING");
setprop("controls/flight/rudder-trim-display", sprintf("%2.1f", getprop("fdm/jsbsim/hydraulics/rudder/trim-cmd-deg")));
setprop("/controls/flight/rudder-trim-display", sprintf("%2.1f", getprop("fdm/jsbsim/hydraulics/rudder/trim-deg")));
start_loop.start();
});
@ -33,27 +33,27 @@ setlistener("instrumentation/chrono[0]/chrono-reset", func(et){
if (tmp == 2) {
if (getprop("instrumentation/chrono[0]/started") == 1) {
if (getprop("instrumentation/chrono[0]/paused") == 0) {
setprop("instrumentation/chrono[0]/elapsetime-sec", 0);
setprop("instrumentation/chrono[0]/chrono-reset", 0);
setprop("/instrumentation/chrono[0]/elapsetime-sec", 0);
setprop("/instrumentation/chrono[0]/chrono-reset", 0);
} else {
chr.stop();
chr.reset();
setprop("instrumentation/chrono[0]/chrono-reset", 1);
setprop("instrumentation/chrono[0]/started", 0);
setprop("instrumentation/chrono[0]/paused", 0);
setprop("/instrumentation/chrono[0]/chrono-reset", 1);
setprop("/instrumentation/chrono[0]/started", 0);
setprop("/instrumentation/chrono[0]/paused", 0);
};
} else {
if (getprop("instrumentation/chrono[0]/paused") == 0) {
# No action required
} else {
setprop("instrumentation/chrono[0]/paused", 0);
setprop("/instrumentation/chrono[0]/paused", 0);
};
};
} elsif (tmp == 1) {
if (getprop("instrumentation/chrono[0]/started") == 1) {
if (getprop("instrumentation/chrono[0]/paused") == 0) {
chr.stop();
setprop("instrumentation/chrono[0]/paused", 1);
setprop("/instrumentation/chrono[0]/paused", 1);
} else {
chr.stop();
};
@ -62,24 +62,24 @@ setlistener("instrumentation/chrono[0]/chrono-reset", func(et){
chr.stop();
} else {
chr.stop();
setprop("instrumentation/chrono[0]/paused", 0);
setprop("/instrumentation/chrono[0]/paused", 0);
};
};
} elsif (tmp == 0) {
if (getprop("instrumentation/chrono[0]/started") == 0) {
if (getprop("instrumentation/chrono[0]/paused") == 0) {
chr.start();
setprop("instrumentation/chrono[0]/started", 1);
setprop("/instrumentation/chrono[0]/started", 1);
} else {
chr.start();
setprop("instrumentation/chrono[0]/paused", 0);
setprop("/instrumentation/chrono[0]/paused", 0);
};
} else {
if (getprop("instrumentation/chrono[0]/paused") == 0) {
# No action required
} else {
chr.start();
setprop("instrumentation/chrono[0]/paused", 0);
setprop("/instrumentation/chrono[0]/paused", 0);
};
};
};
@ -106,34 +106,34 @@ var start_loop = maketimer(0.1, func {
var UTC_date3 = sprintf("%02d", "88");
var clock2_1 = "88:88";
var clock2_2 = sprintf("%02d", 88);
setprop("instrumentation/clock/clock_hh_mm", clock2_1);
setprop("instrumentation/clock/indicated-seconds", clock2_2);
setprop("instrumentation/clock/utc-date", UTC_date);
setprop("instrumentation/clock/utc-date1", UTC_date1);
setprop("instrumentation/clock/utc-date2", UTC_date2);
setprop("instrumentation/clock/utc-date3", UTC_date3);
setprop("instrumentation/chrono[0]/chr-et-string", "88 88");
setprop("instrumentation/clock/elapsed-string", "88:88");
setprop("/instrumentation/clock/clock_hh_mm", clock2_1);
setprop("/instrumentation/clock/indicated-seconds", clock2_2);
setprop("/instrumentation/clock/utc-date", UTC_date);
setprop("/instrumentation/clock/utc-date1", UTC_date1);
setprop("/instrumentation/clock/utc-date2", UTC_date2);
setprop("/instrumentation/clock/utc-date3", UTC_date3);
setprop("/instrumentation/chrono[0]/chr-et-string", "88 88");
setprop("/instrumentation/clock/elapsed-string", "88:88");
} else {
# Clock
var UTC_date = sprintf("%02d %02d %02d", getprop("sim/time/utc/month"), getprop("sim/time/utc/day"), substr(sprintf("%2d", getprop("sim/time/utc/year")),1,2));
setprop("instrumentation/clock/utc-date", UTC_date);
setprop("/instrumentation/clock/utc-date", UTC_date);
var UTC_date1 = sprintf("%02d", getprop("sim/time/utc/month"));
var UTC_date2 = sprintf("%02d", getprop("sim/time/utc/day"));
var UTC_date3 = substr(sprintf("%2d", getprop("sim/time/utc/year")),2,2);
var clock2_1 = getprop("instrumentation/clock/indicated-short-string");
var clock2_2 = sprintf("%02d", substr(getprop("instrumentation/clock/indicated-string"),6,2));
setprop("instrumentation/clock/clock_hh_mm", clock2_1);
setprop("instrumentation/clock/indicated-seconds", clock2_2);
setprop("instrumentation/clock/utc-date", UTC_date);
setprop("instrumentation/clock/utc-date1", UTC_date1);
setprop("instrumentation/clock/utc-date2", UTC_date2);
setprop("instrumentation/clock/utc-date3", UTC_date3);
setprop("/instrumentation/clock/clock_hh_mm", clock2_1);
setprop("/instrumentation/clock/indicated-seconds", clock2_2);
setprop("/instrumentation/clock/utc-date", UTC_date);
setprop("/instrumentation/clock/utc-date1", UTC_date1);
setprop("/instrumentation/clock/utc-date2", UTC_date2);
setprop("/instrumentation/clock/utc-date3", UTC_date3);
if (getprop("instrumentation/clock/set-knob") == "") {
setprop("instrumentation/clock/set-knob", 0);
setprop("/instrumentation/clock/set-knob", 0);
};
if (getprop("instrumentation/clock/utc-selector") == "") {
setprop("instrumentation/clock/utc-selector", 0);
setprop("/instrumentation/clock/utc-selector", 0);
};
# if (getprop("instrumentation/clock/utc-selector") == 0) {
# # To do - GPS mode
@ -148,7 +148,7 @@ var start_loop = maketimer(0.1, func {
# Chrono
var chr_tmp = getprop("instrumentation/chrono[0]/elapsetime-sec");
if (chr_tmp >= 6000) {
setprop("instrumentation/chrono[0]/elapsetime-sec", chr_tmp-6000);
setprop("/instrumentation/chrono[0]/elapsetime-sec", chr_tmp-6000);
};
var chr_min = int(chr_tmp * 0.0166666666667);
if (chr_tmp >= 60) {
@ -156,46 +156,54 @@ var start_loop = maketimer(0.1, func {
} else {
var chr_sec = int(chr_tmp);
};
setprop("instrumentation/chrono[0]/chr-et-min",chr_min);
setprop("instrumentation/chrono[0]/chr-et-sec",chr_sec);
setprop("/instrumentation/chrono[0]/chr-et-min",chr_min);
setprop("/instrumentation/chrono[0]/chr-et-sec",chr_sec);
chr_tmp = sprintf("%02d:%02d", chr_min, chr_sec);
setprop("instrumentation/chrono[0]/chr-et-string", chr_tmp);
setprop("/instrumentation/chrono[0]/chr-et-string", chr_tmp);
# ET clock
var et_tmp = getprop("instrumentation/clock/elapsetime-sec");
if (et_tmp >= 360000) {
setprop("instrumentation/clock/elapsetime-sec", et_tmp-360000);
setprop("/instrumentation/clock/elapsetime-sec", et_tmp-360000);
};
var et_min = int(et_tmp * 0.0166666666667);
var et_hr = int(et_min * 0.0166666666667);
et_min = et_min - (et_hr * 60);
setprop("instrumentation/clock/et-hr",et_hr);
setprop("instrumentation/clock/et-min",et_min);
setprop("/instrumentation/clock/et-hr",et_hr);
setprop("/instrumentation/clock/et-min",et_min);
et_tmp = sprintf("%02d:%02d", et_hr, et_min);
setprop("instrumentation/clock/elapsed-string", et_tmp);
setprop("/instrumentation/clock/elapsed-string", et_tmp);
foreach (item; update_items) {
item.update(nil);
}
};
});
setlistener("fdm/jsbsim/hydraulics/rudder/trim-cmd-deg", func() {
if (systems.ELEC.Bus.dcEss.getValue() < 25 and systems.ELEC.Bus.dc2.getValue() < 25) { return; }
var rudder_val = getprop("fdm/jsbsim/hydraulics/rudder/trim-cmd-deg");
if (getprop("controls/switches/annun-test") == 1) {
setprop("controls/flight/rudder-trim-display", "88.8");
setprop("controls/flight/rudder-trim-letter-display", "8");
} else {
if (rudder_val > -0.05 and rudder_val < 0.05) {
setprop("controls/flight/rudder-trim-display", sprintf("%2.1f", abs(rudder_val)));
setprop("controls/flight/rudder-trim-letter-display", "");
} else {
if (rudder_val >= 0.05) {
setprop("controls/flight/rudder-trim-display", sprintf("%2.1f", abs(rudder_val)));
setprop("controls/flight/rudder-trim-letter-display", "R");
var update_items = [
props.UpdateManager.FromPropertyHashList(["/fdm/jsbsim/hydraulics/rudder/trim-deg", "/controls/switches/annun-test"], 0.05, func(notification)
{
var rudder_val = getprop("fdm/jsbsim/hydraulics/rudder/trim-deg");
if (getprop("/controls/switches/annun-test") == 1) {
setprop("/controls/flight/rudder-trim-display", sprintf("%3.1f", "88.8"));
setprop("/controls/flight/rudder-trim-letter-display", sprintf("%1.0f", "8"));
} else {
if (rudder_val <= -0.05) {
setprop("controls/flight/rudder-trim-display", sprintf("%2.1f", abs(rudder_val)));
setprop("controls/flight/rudder-trim-letter-display", "L");
};
};
};
};
},0, 0);
if (rudder_val > -0.05 and rudder_val < 0.05) {
setprop("/controls/flight/rudder-trim-display", sprintf("%2.1f", abs(rudder_val)));
setprop("/controls/flight/rudder-trim-letter-display", "");
} else {
if (rudder_val >= 0.05) {
setprop("/controls/flight/rudder-trim-display", sprintf("%2.1f", abs(rudder_val)));
setprop("/controls/flight/rudder-trim-letter-display", "R");
} else {
if (rudder_val <= -0.05) {
setprop("/controls/flight/rudder-trim-display", sprintf("%2.1f", abs(rudder_val)));
setprop("/controls/flight/rudder-trim-letter-display", "L");
}
}
}
}
}
),
];

View file

@ -60,8 +60,7 @@
<default value="0"/>
<test logic="OR" value="1">
position/wow eq 1
/it-fbw/law eq 2
/it-fbw/law eq 3
/it-fbw/yaw-law eq 2
</test>
</switch>
@ -1542,8 +1541,8 @@
<switch name="fbw/yaw/law-switch">
<default value="0"/>
<test logic="OR" value="1">
/it-fbw/law eq 0
/it-fbw/law eq 1
/it-fbw/yaw-law eq 0
/it-fbw/yaw-law eq 1
</test>
</switch>

View file

@ -333,13 +333,44 @@
</test>
</switch>
<switch name="hydraulics/rudder/trim-autopilot">
<default value="0"/>
<test logic="AND" value="/controls/flight/rudder-trim">
/it-autoflight/output/ap1 eq 0
/it-autoflight/output/ap2 eq 0
</test>
</switch>
<pure_gain name="hydraulics/rudder/trim-cmd-deg">
<input>/controls/flight/rudder-trim</input>
<input>hydraulics/rudder/trim-autopilot</input>
<gain>20</gain>
</pure_gain>
<switch name="hydraulics/rudder/trim-rate">
<default value="0"/>
<test logic="OR" value="1">
<test logic="AND">
/systems/electrical/bus/dc-ess ge 25
/systems/fctl/fac1 eq 1
</test>
<test logic="AND">
/systems/electrical/bus/dc-2 ge 25
/systems/fctl/fac2 eq 1
</test>
</test>
</switch>
<actuator name="hydraulics/rudder/trim-deg">
<input>hydraulics/rudder/trim-cmd-deg</input>
<rate_limit>hydraulics/rudder/trim-rate</rate_limit>
</actuator>
<aerosurface_scale name="hydraulics/rudder/trim-norm">
<input>/controls/flight/rudder-trim</input>
<input>hydraulics/rudder/trim-deg</input>
<domain>
<min>-20</min>
<max> 20</max>
</domain>
<range>
<min>-0.8</min>
<max>0.8</max>