1
0
Fork 0

Improvements for brakes, merge two brake nasal files and use PTS / props.globals for brakes

This commit is contained in:
legoboyvdlp R 2020-07-26 00:13:54 +01:00
parent c3c56e34ae
commit 6b9209bd08
8 changed files with 192 additions and 131 deletions

View file

@ -4209,7 +4209,6 @@
<file>Aircraft/A320-family/Nasal/Systems/ADIRS/ADR.nas</file>
<file>Aircraft/A320-family/Nasal/Panels/SwitchingPanel.nas</file>
<file>Aircraft/A320-family/Nasal/Systems/Comm/HF.nas</file>
<file>Aircraft/A320-family/Nasal/Systems/brakes.nas</file>
<file>Aircraft/A320-family/Nasal/Systems/brakesystem.nas</file>
<file>Aircraft/A320-family/Nasal/Systems/fire.nas</file>
<file>Aircraft/A320-family/Nasal/Systems/ground_services.nas</file>

View file

@ -519,7 +519,7 @@ var takeoff = func {
setprop("/controls/atc/mode-knob", 4);
atc.transponderPanel.modeSwitch(5);
setprop("/controls/flight/elevator-trim", -0.07);
systems.arm_autobrake(3);
systems.Autobrake.arm_autobrake(3);
setprop("/ECAM/to-config-test", 1);
settimer(func {
setprop("/ECAM/to-config-test", 0);

View file

@ -1630,10 +1630,10 @@
</condition>
<command>nasal</command>
<script>
if (getprop("controls/autobrake/mode") != 1) {
systems.arm_autobrake(1);
if (systems.Autobrake.mode.getValue() != 1) {
systems.Autobrake.arm_autobrake(1);
} else {
systems.arm_autobrake(0);
systems.Autobrake.arm_autobrake(0);
}
setprop("sim/sounde/oh-btn", 1);
</script>
@ -1657,10 +1657,10 @@
</condition>
<command>nasal</command>
<script>
if (getprop("controls/autobrake/mode") != 2) {
systems.arm_autobrake(2);
if (systems.Autobrake.mode.getValue() != 2) {
systems.Autobrake.arm_autobrake(2);
} else {
systems.arm_autobrake(0);
systems.Autobrake.arm_autobrake(0);
}
setprop("sim/sounde/oh-btn", 1);
</script>
@ -1684,10 +1684,10 @@
</condition>
<command>nasal</command>
<script>
if (getprop("controls/autobrake/mode") != 3) {
systems.arm_autobrake(3);
if (systems.Autobrake.mode.getValue() != 3) {
systems.Autobrake.arm_autobrake(3);
} else {
systems.arm_autobrake(0);
systems.Autobrake.arm_autobrake(0);
}
setprop("sim/sounde/oh-btn", 1);
</script>
@ -6243,7 +6243,7 @@
<type>rotate</type>
<object-name>LRudderPedalL</object-name>
<object-name>LRudderPedalR</object-name>
<property>controls/gear/brake-left</property>
<property>/fdm/jsbsim/fcs/brake-left</property>
<factor>15</factor>
<axis>
<x>0</x>
@ -6261,7 +6261,7 @@
<type>rotate</type>
<object-name>RRudderPedalL</object-name>
<object-name>RRudderPedalR</object-name>
<property>controls/gear/brake-right</property>
<property>/fdm/jsbsim/fcs/brake-right</property>
<factor>15</factor>
<axis>
<x>0</x>

View file

@ -188,7 +188,7 @@ var systemsInit = func {
systems.ADIRS.init();
systems.eng_init();
systems.APUController.init();
systems.autobrake_init();
systems.Autobrake.init();
systems.fire_init();
fmgc.flightPlanController.reset();
fmgc.windController.reset();

View file

@ -4,6 +4,10 @@
# Anything that says Temp is set by another file to avoid multiple getValue calls
# Usage Example: pts.Class.SubClass.node.getValue()
var Acconfig = {
running: props.globals.getNode("/systems/acconfig/autoconfig-running"),
};
var APU = {
masterSw: props.globals.getNode("/controls/apu/master"),
rpm: props.globals.getNode("/engines/engine[2]/n1"),
@ -37,6 +41,7 @@ var Controls = {
rudderTrim: props.globals.getNode("/controls/flight/rudder-trim"),
},
Gear: {
brake: [props.globals.getNode("/controls/gear/brake-left"),props.globals.getNode("/controls/gear/brake-right")],
gearDown: props.globals.getNode("/controls/gear/gear-down"),
parkingBrake: props.globals.getNode("/controls/gear/brake-parking"),
},

View file

@ -1,80 +0,0 @@
# A3XX Autobrake
# Joshua Davidson (Octal450)
# Copyright (c) 2020 Josh Davidson (Octal450)
var thr1 = 0;
var thr2 = 0;
var wow0 = 0;
var gnd_speed = 0;
setprop("controls/autobrake/active", 0);
setprop("controls/autobrake/mode", 0);
setprop("controls/autobrake/decel-rate", 0);
var autobrake_init = func {
setprop("controls/autobrake/active", 0);
setprop("controls/autobrake/mode", 0);
}
# Override FG's generic brake
controls.applyBrakes = func(v, which = 0) {
if (getprop("systems/acconfig/autoconfig-running") != 1) {
if (which <= 0) {
interpolate("/controls/gear/brake-left", v, 0.5);
}
if (which >= 0) {
interpolate("/controls/gear/brake-right", v, 0.5);
}
}
}
# Set autobrake mode
var arm_autobrake = func(mode) {
wow0 = getprop("gear/gear[0]/wow");
gnd_speed = getprop("velocities/groundspeed-kt");
if (mode == 0) { # OFF
absChk.stop();
if (getprop("controls/autobrake/active") == 1) {
setprop("controls/autobrake/active", 0);
setprop("controls/gear/brake-left", 0);
setprop("controls/gear/brake-right", 0);
}
setprop("controls/autobrake/decel-rate", 0);
setprop("controls/autobrake/mode", 0);
} else if (mode == 1 and wow0 != 1) { # LO
setprop("controls/autobrake/decel-rate", 1.7);
setprop("controls/autobrake/mode", 1);
absChk.start();
} else if (mode == 2 and wow0 != 1) { # MED
setprop("controls/autobrake/decel-rate", 3);
setprop("controls/autobrake/mode", 2);
absChk.start();
} else if (mode == 3 and wow0 == 1 and gnd_speed < 40) { # MAX
setprop("controls/autobrake/decel-rate", 6);
setprop("controls/autobrake/mode", 3);
absChk.start();
}
}
# Autobrake loop
var absChk = maketimer(0.2, func {
thr1 = getprop("controls/engines/engine[0]/throttle");
thr2 = getprop("controls/engines/engine[1]/throttle");
wow0 = getprop("gear/gear[0]/wow");
gnd_speed = getprop("velocities/groundspeed-kt");
if (gnd_speed > 72) {
if (getprop("controls/autobrake/mode") != 0 and thr1 < 0.15 and thr2 < 0.15 and wow0 == 1) {
setprop("controls/autobrake/active", 1);
} else {
setprop("controls/autobrake/active", 0);
setprop("controls/gear/brake-left", 0);
setprop("controls/gear/brake-right", 0);
}
}
if (getprop("controls/autobrake/mode") == 3 and getprop("controls/gear/gear-down") == 0) {
arm_autobrake(0);
}
if (getprop("controls/autobrake/mode") != 0 and wow0 == 1 and getprop("controls/autobrake/active") == 1 and (getprop("controls/gear/brake-left") > 0.05 or getprop("controls/gear/brake-right") > 0.05)) {
arm_autobrake(0);
}
});

View file

@ -1,3 +1,9 @@
# A3XX Autobrake and Braking
# Joshua Davidson (Octal450)
# Copyright (c) 2020 Josh Davidson (Octal450)
##########################################################################
# Simple Brake Simulation System
# 2010, Thorsten Brehm
@ -63,7 +69,7 @@ var BrakeSystem =
setprop("gear/gear[1]/Lbrake-thermal-energy",0.0);
setprop("gear/gear[2]/Rbrake-thermal-energy",0.0);
setprop("controls/gear/brake-fans",0);
setprop("/controls/gear/brake-fans",0);
setprop("gear/gear[1]/Lbrake-smoke",0);
setprop("gear/gear[2]/Rbrake-smoke",0);
setprop("gear/gear[1]/L-Thrust",0);
@ -80,21 +86,21 @@ var BrakeSystem =
var tatdegc = getprop("/systems/navigation/probes/tat-1/compute-tat") or 0;
var atemp = getprop("environment/temperature-degc") or 0;
var vmach = getprop("velocities/mach") or 0;
var tatdegc = getprop("systems/navigation/probes/tat-1/compute-tat");
var tatdegc = getprop("/systems/navigation/probes/tat-1/compute-tat");
setprop("gear/gear[1]/L1brake-temp-degc",tatdegc+getprop("gear/gear[1]/L1error-temp-degc"));
setprop("gear/gear[1]/L2brake-temp-degc",tatdegc+getprop("gear/gear[1]/L2error-temp-degc"));
setprop("gear/gear[2]/R3brake-temp-degc",tatdegc+getprop("gear/gear[2]/R3error-temp-degc"));
setprop("gear/gear[2]/R4brake-temp-degc",tatdegc+getprop("gear/gear[2]/R4error-temp-degc"));
setprop("sim/animation/fire-services",0);
setprop("/sim/animation/fire-services",0);
me.LastSimTime = 0.0;
},
# update brake energy
update : func()
{
var CurrentTime = getprop("sim/time/elapsed-sec");
var CurrentTime = getprop("/sim/time/elapsed-sec");
var dt = CurrentTime - me.LastSimTime;
var LThermalEnergy = getprop("gear/gear[1]/Lbrake-thermal-energy");
var RThermalEnergy = getprop("gear/gear[2]/Rbrake-thermal-energy");
@ -107,12 +113,12 @@ var BrakeSystem =
var L_thrust_lb = getprop("engines/engine[0]/thrust_lb");
var R_thrust_lb = getprop("engines/engine[1]/thrust_lb");
if (getprop("sim/freeze/replay-state")==0 and dt<1.0) {
if (getprop("/sim/freeze/replay-state")==0 and dt<1.0) {
var OnGround = getprop("gear/gear[1]/wow");
#cooling effect: adjust cooling factor by a value proportional to the environment temp (m.CoolingFactor + environment temp-degc * 0.00001)
var LCoolingRatio = me.CoolingFactor+(tatdegc*0.000001);
var RCoolingRatio = me.CoolingFactor+(tatdegc*0.000001);
if (getprop("controls/gear/brake-fans")) {
if (getprop("/controls/gear/brake-fans")) {
#increase CoolingRatio if Brake Fans are active
LCoolingRatio = LCoolingRatio * 3;
RCoolingRatio = RCoolingRatio * 3;
@ -169,8 +175,8 @@ var BrakeSystem =
var V2_R = V1 - me.BrakeDecel * dt * RBrakeLevel;
LThermalEnergy += (Mass * getprop("gear/gear[1]/compression-norm") * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2);
if (getprop("services/chocks/enable")) {
if (!getprop("controls/gear/brake-parking")) {
if (getprop("/services/chocks/enable")) {
if (!getprop("/controls/gear/brake-parking")) {
# cooling effect: reduce thermal energy by (LnCoolFactor) * dt
LThermalEnergy = LThermalEnergy * math.exp(LnCoolFactor * dt);
} else {
@ -179,7 +185,7 @@ var BrakeSystem =
LThermalEnergy = (LThermalEnergy * math.exp(LnCoolFactor * dt)) + (L_Thrust * dt);
};
} else {
if (!getprop("controls/gear/brake-parking")) {
if (!getprop("/controls/gear/brake-parking")) {
if (LBrakeLevel>0) {
if (V2_L>0) {
#LThermalEnergy += (Mass * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2) + L_thrust;
@ -202,8 +208,8 @@ var BrakeSystem =
};
RThermalEnergy += (Mass * getprop("gear/gear[2]/compression-norm") * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2);
if (getprop("services/chocks/enable")) {
if (!getprop("controls/gear/brake-parking")) {
if (getprop("/services/chocks/enable")) {
if (!getprop("/controls/gear/brake-parking")) {
# cooling effect: reduce thermal energy by (RnCoolFactor) * dt
RThermalEnergy = RThermalEnergy * math.exp(RnCoolFactor * dt);
} else {
@ -212,7 +218,7 @@ var BrakeSystem =
RThermalEnergy = (RThermalEnergy * math.exp(RnCoolFactor * dt)) + (R_Thrust * dt);
};
} else {
if (!getprop("controls/gear/brake-parking")) {
if (!getprop("/controls/gear/brake-parking")) {
if (RBrakeLevel>0) {
if (V2_R>0) {
#RThermalEnergy += (Mass * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2) + R_thrust;
@ -304,13 +310,13 @@ var BrakeSystem =
} else {
# stop smoke processing
setprop("gear/gear[1]/Lbrake-smoke",0);
setprop("sim/animation/fire-services",0);
setprop("/sim/animation/fire-services",0);
me.LSmokeActive = 0;
};
if (getprop("gear/gear[1]/Lbrake-thermal-energy") > 1.5) {
setprop("sim/animation/fire-services",1);
setprop("/sim/animation/fire-services",1);
} else {
setprop("sim/animation/fire-services",0);
setprop("/sim/animation/fire-services",0);
};
},
@ -344,21 +350,102 @@ var BrakeSystem =
me.RSmokeActive = 0;
};
if (getprop("gear/gear[2]/Rbrake-thermal-energy") > 1.5) {
setprop("sim/animation/fire-services",1);
setprop("/sim/animation/fire-services",1);
} else {
setprop("sim/animation/fire-services",0);
setprop("/sim/animation/fire-services",0);
};
},
};
var BrakeSys = BrakeSystem.new();
setlistener("sim/signals/fdm-initialized",
#############
# Autobrake #
#############
var Autobrake = {
active: props.globals.initNode("/controls/autobrake/active", 0, "BOOL"),
mode: props.globals.initNode("/controls/autobrake/mode", 0, "INT"),
decel: props.globals.initNode("/controls/autobrake/decel-rate", 0, "DOUBLE"),
_wow0: 0,
_gnd_speed: 0,
_mode: 0,
_active: 0,
init: func() {
me.active.setBoolValue(0);
me.mode.setValue(0);
me.decel.setValue(0);
},
arm_autobrake: func(mode) {
me._wow0 = pts.Gear.wow[0].getBoolValue();
me._gnd_speed = pts.Velocities.groundspeed.getValue();
if (mode == 0) { # OFF
absChk.stop();
if (me.active.getBoolValue()) {
me.active.setBoolValue(0);
pts.Controls.Gear.brake[0].setValue(0);
pts.Controls.Gear.brake[1].setValue(0);
}
me.decel.setValue(0);
me.mode.setValue(0);
} else if (mode == 1 and !me._wow0) { # LO
me.decel.setValue(2.0);
me.mode.setValue(1);
absChk.start();
} else if (mode == 2 and !me._wow0) { # MED
me.decel.setValue(3);
me.mode.setValue(2);
absChk.start();
} else if (mode == 3 and me._wow0 and me._gnd_speed < 40) { # MAX
me.decel.setValue(6);
me.mode.setValue(3);
absChk.start();
}
},
loop: func() {
me._wow0 = pts.Gear.wow[0].getBoolValue();
me._gnd_speed = pts.Velocities.groundspeed.getValue();
me._mode = me.mode.getValue();
me._active = me.active.getBoolValue();
if (me._gnd_speed > 72) {
if (me._mode != 0 and pts.Controls.Engines.Engine.throttle[0].getValue() < 0.15 and pts.Controls.Engines.Engine.throttle[1].getValue() < 0.15 and me._wow0) {
me.active.setBoolValue(1);
} elsif (me._active) {
me.active.setBoolValue(0);
pts.Controls.Gear.brake[0].setValue(0);
pts.Controls.Gear.brake[1].setValue(0);
}
}
if (me._mode == 3 and !pts.Controls.Gear.gearDown.getBoolValue()) {
me.arm_autobrake(0);
}
if (me._mode != 0 and me._wow0 and me._active and (pts.Controls.Gear.brake[0].getValue() > 0.05 or pts.Controls.Gear.brake[1].getValue() > 0.05)) {
me.arm_autobrake(0);
}
},
};
# Override FG's generic brake
controls.applyBrakes = func(v, which = 0) {
if (!pts.Acconfig.running.getBoolValue()) {
if (which <= 0) {
pts.Controls.Gear.brake[0].setValue(v);
}
if (which >= 0) {
pts.Controls.Gear.brake[1].setValue(v);
}
}
}
setlistener("/sim/signals/fdm-initialized",
# executed on _every_ FDM reset (but not installing new listeners)
func(idle) { BrakeSys.reset(); },
0,0);
settimer(func()
{
BrakeSys.update();
}, 5);
settimer(func() { BrakeSys.update(); }, 5);
# Autobrake loop
var absChk = maketimer(0.2, func {
Autobrake.loop();
});

View file

@ -1087,38 +1087,88 @@
<c1>20</c1>
</lag_filter>
<summer name="fcs/left-brake-summer">
<actuator name="fcs/brake-left">
<input>/controls/gear/brake-left</input>
<input>/controls/gear/brake-parking</input>
<input>/services/chocks/enable</input>
<rate_limit>2</rate_limit>
</actuator>
<actuator name="fcs/brake-right">
<input>/controls/gear/brake-right</input>
<rate_limit>2</rate_limit>
</actuator>
<switch name="fcs/brake-avail">
<default value="1"/>
<!--<test logic="OR" value="1">
/systems/hydraulic/green-psi ge 2000
/systems/hydraulic/yellow-psi ge 1500
</test>-->
</switch>
<fcs_function name="fcs/left-brake-input">
<function>
<product>
<property>fcs/brake-avail</property>
<max>
<property>/services/chocks/enable</property>
<property>fcs/brake-left</property>
<product>
<property>/controls/autobrake/brake-left</property>
<property>/controls/autobrake/active</property>
</product>
<property>/controls/gear/brake-parking</property>
</max>
</product>
</function>
<clipto>
<min>0</min>
<max>1</max>
</clipto>
</summer>
</fcs_function>
<actuator name="fcs/left-brake-actuator">
<input>fcs/left-brake-input</input>
<rate_limit>10</rate_limit>
</actuator>
<switch name="rubbish/left-brake-cmd-norm">
<default value="fcs/left-brake-summer"/>
<test value="/controls/autobrake/brake-left">
/controls/autobrake/active eq 1
<default value="fcs/left-brake-actuator"/>
<test value="1">
/systems/acconfig/autoconfig-running eq 1
</test>
<output>fcs/left-brake-cmd-norm</output>
</switch>
<summer name="fcs/right-brake-summer">
<input>/controls/gear/brake-right</input>
<input>/controls/gear/brake-parking</input>
<input>/services/chocks/enable</input>
<fcs_function name="fcs/right-brake-input">
<function>
<product>
<property>fcs/brake-avail</property>
<max>
<property>/services/chocks/enable</property>
<property>fcs/brake-right</property>
<product>
<property>/controls/autobrake/brake-right</property>
<property>/controls/autobrake/active</property>
</product>
<property>/controls/gear/brake-parking</property>
</max>
</product>
</function>
<clipto>
<min>0</min>
<max>1</max>
</clipto>
</summer>
</fcs_function>
<actuator name="fcs/right-brake-actuator">
<input>fcs/right-brake-input</input>
<rate_limit>10</rate_limit>
</actuator>
<switch name="rubbish/right-brake-cmd-norm">
<default value="fcs/right-brake-summer"/>
<test value="/controls/autobrake/brake-right">
/controls/autobrake/active eq 1
<default value="fcs/right-brake-actuator"/>
<test value="1">
/systems/acconfig/autoconfig-running eq 1
</test>
<output>fcs/right-brake-cmd-norm</output>
</switch>