icing update

This commit is contained in:
Jonathan Redpath 2017-06-21 18:21:27 +01:00
parent b0d2265368
commit 4148c374c3
11 changed files with 573 additions and 504 deletions

View file

@ -24,36 +24,42 @@
<icing>
<iceable>
<name>Wing</name>
<ice-inches>0.0</ice-inches>
<salvage-control>/controls/deice/wing</salvage-control>
<sensitivity type="double">0.8</sensitivity>
<output-property>/fdm/jsbsim/ice/wing</output-property>
</iceable>
<iceable>
<name>LeftEngine</name>
<ice-inches>0.0</ice-inches>
<salvage-control>/controls/deice/lengine</salvage-control>
<sensitivity type="double">0.5</sensitivity>
<output-property>/fdm/jsbsim/ice/lengine</output-property>
</iceable>
<iceable>
<name>RightEngine</name>
<ice-inches>0.0</ice-inches>
<salvage-control>/controls/deice/rengine</salvage-control>
<sensitivity type="double">0.5</sensitivity>
<output-property>/fdm/jsbsim/ice/rengine</output-property>
</iceable>
<iceable>
<name>Windshield</name>
<ice-inches>0.0</ice-inches>
<salvage-control>/controls/deice/windowprobeheat</salvage-control>
<sensitivity type="double">0.5</sensitivity>
<!-- not relevant for fdm, ignore output-property -->
</iceable>
<iceable>
<name>Fuselage</name>
<ice-inches>0.0</ice-inches>
<!-- no salvage control, no deicing of the fuselage -->
<sensitivity type="double">0.3</sensitivity>
<output-property>/fdm/jsbsim/ice/fuselage</output-property>
</iceable>
<iceable>
<name>Pitot tube</name>
<ice-inches>0.0</ice-inches>
<sensitivity type="double">1</sensitivity>
<salvage-control>/controls/deice/windowprobeheat</salvage-control>
<output-property>/systems/pitot/icing</output-property>

View file

@ -102,6 +102,7 @@ var systemsReset = func {
fmgc.FMGCinit();
mcdu1.MCDU_reset();
mcdu2.MCDU_reset();
icing.PitotIcingReset();
fmgc.APinit();
setprop("/it-autoflight/input/fd1", 1);
setprop("/it-autoflight/input/fd2", 1);

View file

@ -111,6 +111,9 @@
<object-name>YellowElecPump2O</object-name>
<object-name>YellowEngPump1F</object-name>
<object-name>YellowEngPump2O</object-name>
<object-name>PrbWinHeatBtn2</object-name>
<object-name>PrbWinHeatBtn2O</object-name>
<object-name>PrbWinHeatBtn1</object-name>
<condition>
<or>
<greater-than-equals>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View file

@ -8,7 +8,237 @@ MATERIAL "OHPanelOnBat" rgb 0.8 0.8 0.8 amb 1 1 1 emis 1 1 1 spec 0.5 0.5 0.5
MATERIAL "Switch" rgb 0.678431 0.678431 0.678431 amb 0.678431 0.678431 0.678431 emis 0 0 0 spec 0 0 0 shi 32 trans 0.004
MATERIAL "ac3dmat1" rgb 1 1 1 amb 1 1 1 emis 0 0 0 spec 1 1 1 shi 128 trans 0
OBJECT world
kids 267
kids 272
OBJECT poly
name "WingAntiIceBtn2O"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.039
texture "buttons5.png"
crease 30.000000
numvert 8
-0.007 -0.2282 0.1337
-0.007 -0.2282 0.1537
-0.01 -0.2282 0.1537
-0.01 -0.2282 0.1337
-0.007 -0.2182 0.1337
-0.007 -0.2182 0.1537
-0.01 -0.2182 0.1537
-0.01 -0.2182 0.1337
numsurf 4
SURF 0x0
mat 4
refs 4
0 0.5 0.5
1 0 0.5
2 0 0.5
3 0.5 0.5
SURF 0x0
mat 4
refs 4
0 0.5 0.5
4 0.5 0.75
5 9.31321e-008 0.75
1 0 0.5
SURF 0x0
mat 4
refs 4
1 0 0.5
5 9.31321e-008 0.75
6 9.31321e-008 0.75
2 0 0.5
SURF 0x0
mat 4
refs 4
4 0.5 0.75
0 0.5 0.5
3 0.5 0.5
7 0.5 0.75
kids 0
OBJECT poly
name "Eng2AntiIceBtn2O"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.035
texture "buttons5.png"
crease 30.000000
numvert 8
-0.007 -0.2282 0.0329
-0.007 -0.2282 0.0529
-0.01 -0.2282 0.0529
-0.01 -0.2282 0.0329
-0.007 -0.2182 0.0329
-0.007 -0.2182 0.0529
-0.01 -0.2182 0.0529
-0.01 -0.2182 0.0329
numsurf 4
SURF 0x0
mat 4
refs 4
0 0.5 0.5
1 0 0.5
2 0 0.5
3 0.5 0.5
SURF 0x0
mat 4
refs 4
0 0.5 0.5
4 0.5 0.75
5 9.31321e-008 0.75
1 0 0.5
SURF 0x0
mat 4
refs 4
1 0 0.5
5 9.31321e-008 0.75
6 9.31321e-008 0.75
2 0 0.5
SURF 0x0
mat 4
refs 4
4 0.5 0.75
0 0.5 0.5
3 0.5 0.5
7 0.5 0.75
kids 0
OBJECT poly
name "Eng2AntiIceBtn1F"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.036
texture "buttons5.png"
crease 30.000000
numvert 8
-0.007 -0.2182 0.0329
-0.007 -0.2182 0.0529
-0.01 -0.2182 0.0529
-0.01 -0.2182 0.0329
-0.007 -0.2082 0.0329
-0.007 -0.2082 0.0529
-0.01 -0.2082 0.0529
-0.01 -0.2082 0.0329
numsurf 4
SURF 0x0
mat 4
refs 4
4 0.503906 0.492188
7 0.503906 0.492188
6 0.00390634 0.492188
5 0.00390634 0.492188
SURF 0x0
mat 4
refs 4
0 0.503906 0.242188
4 0.503906 0.492188
5 0.00390634 0.492188
1 0.00390625 0.242188
SURF 0x0
mat 4
refs 4
1 0.00390625 0.242188
5 0.00390634 0.492188
6 0.00390634 0.492188
2 0.00390625 0.242188
SURF 0x0
mat 4
refs 4
4 0.503906 0.492188
0 0.503906 0.242188
3 0.503906 0.242188
7 0.503906 0.492188
kids 0
OBJECT poly
name "Eng1AntiIceBtn1F"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.037
texture "buttons5.png"
crease 30.000000
numvert 8
-0.007 -0.2182 0.0653
-0.007 -0.2182 0.0853
-0.01 -0.2182 0.0853
-0.01 -0.2182 0.0653
-0.007 -0.2082 0.0653
-0.007 -0.2082 0.0853
-0.01 -0.2082 0.0853
-0.01 -0.2082 0.0653
numsurf 4
SURF 0x0
mat 4
refs 4
4 0.501459 0.501976
7 0.501459 0.501976
6 0.0014592 0.501976
5 0.0014592 0.501976
SURF 0x0
mat 4
refs 4
0 0.501459 0.251976
4 0.501459 0.501976
5 0.0014592 0.501976
1 0.00145911 0.251976
SURF 0x0
mat 4
refs 4
1 0.00145911 0.251976
5 0.0014592 0.501976
6 0.0014592 0.501976
2 0.00145911 0.251976
SURF 0x0
mat 4
refs 4
4 0.501459 0.501976
0 0.501459 0.251976
3 0.501459 0.251976
7 0.501459 0.501976
kids 0
OBJECT poly
name "Eng1AntiIceBtn2O"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.038
texture "buttons5.png"
crease 30.000000
numvert 8
-0.007 -0.2282 0.0653
-0.007 -0.2282 0.0853
-0.01 -0.2282 0.0853
-0.01 -0.2282 0.0653
-0.007 -0.2182 0.0653
-0.007 -0.2182 0.0853
-0.01 -0.2182 0.0853
-0.01 -0.2182 0.0653
numsurf 4
SURF 0x0
mat 4
refs 4
0 0.5 0.5
1 0 0.5
2 0 0.5
3 0.5 0.5
SURF 0x0
mat 4
refs 4
0 0.5 0.5
4 0.5 0.75
5 9.31321e-008 0.75
1 0 0.5
SURF 0x0
mat 4
refs 4
1 0 0.5
5 9.31321e-008 0.75
6 9.31321e-008 0.75
2 0 0.5
SURF 0x0
mat 4
refs 4
4 0.5 0.75
0 0.5 0.5
3 0.5 0.5
7 0.5 0.75
kids 0
OBJECT poly
name "PrbWinHeatBtn2O"
loc 0.000113685 -5.00064e-005 -4.99785e-005
@ -15209,52 +15439,6 @@ refs 4
2 9.31321e-008 1
kids 0
OBJECT poly
name "Eng1AntiIceBtn2"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.038
texture "buttons.png"
crease 30.000000
numvert 8
-0.01 -0.2182 0.0653
-0.01 -0.2182 0.0853
-0.007 -0.2182 0.0853
-0.007 -0.2182 0.0653
-0.01 -0.2282 0.0653
-0.01 -0.2282 0.0853
-0.007 -0.2282 0.0853
-0.007 -0.2282 0.0653
numsurf 4
SURF 0x0
mat 4
refs 4
3 0.5 0.75
7 0.5 0.5
4 0.5 0.5
0 0.5 0.75
SURF 0x0
mat 4
refs 4
6 0 0.5
2 9.31321e-008 0.75
1 9.31321e-008 0.75
5 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
3 0.5 0.75
2 9.31321e-008 0.75
6 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
6 0 0.5
5 0 0.5
4 0.5 0.5
kids 0
OBJECT poly
name "Eng1BleedBtn1"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
@ -15869,52 +16053,6 @@ refs 4
2 9.31321e-008 1
kids 0
OBJECT poly
name "Eng2AntiIceBtn2"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.035
texture "buttons.png"
crease 30.000000
numvert 8
-0.01 -0.2182 0.0329
-0.01 -0.2182 0.0529
-0.007 -0.2182 0.0529
-0.007 -0.2182 0.0329
-0.01 -0.2282 0.0329
-0.01 -0.2282 0.0529
-0.007 -0.2282 0.0529
-0.007 -0.2282 0.0329
numsurf 4
SURF 0x0
mat 4
refs 4
3 0.5 0.75
7 0.5 0.5
4 0.5 0.5
0 0.5 0.75
SURF 0x0
mat 4
refs 4
6 0 0.5
2 9.31321e-008 0.75
1 9.31321e-008 0.75
5 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
3 0.5 0.75
2 9.31321e-008 0.75
6 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
6 0 0.5
5 0 0.5
4 0.5 0.5
kids 0
OBJECT poly
name "Eng2BleedBtn1"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
@ -32448,7 +32586,7 @@ name "WingAntiIceBtn1"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.040
texture "buttons.png"
texture "buttons5.png"
crease 30.000000
numvert 8
-0.01 -0.2082 0.1337
@ -32463,31 +32601,31 @@ numsurf 4
SURF 0x0
mat 4
refs 4
3 0.5 1
7 0.5 0.75
4 0.5 0.75
0 0.5 1
3 0.503906 0.492188
7 0.503906 0.242188
4 0.503906 0.242188
0 0.503906 0.492188
SURF 0x0
mat 4
refs 4
6 0 0.75
2 9.31321e-008 1
1 9.31321e-008 1
5 0 0.75
6 0.00390625 0.242188
2 0.00390634 0.492188
1 0.00390634 0.492188
5 0.00390625 0.242188
SURF 0x0
mat 4
refs 4
7 0.5 0.75
3 0.5 1
2 9.31321e-008 1
6 0 0.75
7 0.503906 0.242188
3 0.503906 0.492188
2 0.00390634 0.492188
6 0.00390625 0.242188
SURF 0x0
mat 4
refs 4
3 0.5 1
0 0.5 1
1 9.31321e-008 1
2 9.31321e-008 1
3 0.503906 0.492188
0 0.503906 0.492188
1 0.00390634 0.492188
2 0.00390634 0.492188
kids 0
OBJECT poly
name "WingAntiIceBtn2"
@ -35105,3 +35243,95 @@ refs 4
3 0.5 0.5
7 0.5 0.75
kids 0
OBJECT poly
name "Eng1AntiIceBtn2"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.038
texture "buttons.png"
crease 30.000000
numvert 8
-0.01 -0.2182 0.0653
-0.01 -0.2182 0.0853
-0.007 -0.2182 0.0853
-0.007 -0.2182 0.0653
-0.01 -0.2282 0.0653
-0.01 -0.2282 0.0853
-0.007 -0.2282 0.0853
-0.007 -0.2282 0.0653
numsurf 4
SURF 0x0
mat 4
refs 4
3 0.5 0.75
7 0.5 0.5
4 0.5 0.5
0 0.5 0.75
SURF 0x0
mat 4
refs 4
6 0 0.5
2 9.31321e-008 0.75
1 9.31321e-008 0.75
5 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
3 0.5 0.75
2 9.31321e-008 0.75
6 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
6 0 0.5
5 0 0.5
4 0.5 0.5
kids 0
OBJECT poly
name "Eng2AntiIceBtn2"
loc 0.000113685 -5.00064e-005 -4.99785e-005
data 8
Cube.035
texture "buttons.png"
crease 30.000000
numvert 8
-0.01 -0.2182 0.0329
-0.01 -0.2182 0.0529
-0.007 -0.2182 0.0529
-0.007 -0.2182 0.0329
-0.01 -0.2282 0.0329
-0.01 -0.2282 0.0529
-0.007 -0.2282 0.0529
-0.007 -0.2282 0.0329
numsurf 4
SURF 0x0
mat 4
refs 4
3 0.5 0.75
7 0.5 0.5
4 0.5 0.5
0 0.5 0.75
SURF 0x0
mat 4
refs 4
6 0 0.5
2 9.31321e-008 0.75
1 9.31321e-008 0.75
5 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
3 0.5 0.75
2 9.31321e-008 0.75
6 0 0.5
SURF 0x0
mat 4
refs 4
7 0.5 0.5
6 0 0.5
5 0 0.5
4 0.5 0.5
kids 0

View file

@ -1,80 +1,35 @@
#############################################################################
# This file is part of FlightGear, the free flight simulator
# http://www.flightgear.org/
#
# Copyright (C) 2009 Torsten Dreyer, Torsten (at) t3r _dot_ de
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#############################################################################
######################################################
# Fail the pitot tude due to icing of the pitot tube #
# Code by Jonathan Redpath #
######################################################
#########################################################################################
# Fail the airspeed indicator due to icing of the pitot tube
# Maintainer: Torsten Dreyer (Torsten at t3r dot de)
#
# inputs
# /instrumentation/airspeed-indicator[n]/icing
#
# outputs
# /instrumentation/airspeed-indicator/serviceable
# /instrumentation/airspeed-indicator/indicated-speed-kt
#########################################################################################
var PitotIcingReset = func {
setprop("/systems/pitot/icing", 0.0);
setprop("/systems/pitot/failed", 1);
pitot_timer.start();
}
var PitotIcingHandler = {};
PitotIcingHandler.new = func {
var m = {};
m.parents = [PitotIcingHandler];
PitotIcing = func {
var icing = getprop("/systems/pitot/icing");
var failed = getprop("/systems/pitot/failed");
m.failAtIcelevel = arg[1];
m.baseNodeName = "/systems/pitot[" ~ arg[0] ~ "]";
print( "creating PitotIcingHandler for " ~ m.baseNodeName );
m.baseN = props.globals.getNode( m.baseNodeName );
m.icingN = m.baseN.initNode( "icing", 0.0 );
m.serviceableN = m.baseN.initNode( "serviceable", 1, "BOOL" );
setlistener( m.icingN, func { m.listener() } );
return m;
if( icing > 0.03 ) {
if( !failed ) {
setprop("/systems/pitot/failed", 1);
}
} else if( icing > 0.03 ) {
if( failed ) {
setprop("/systems/pitot/failed", 0);
}
}
};
#########################################################################################
# The handler. Check if ice is above threshold, then fail the device
#########################################################################################
###################
# Update Function #
###################
PitotIcingHandler.listener = func {
var update_pitotIcing = func {
PitotIcing();
}
if( me.icingN.getValue() < me.failAtIcelevel ) {
# everything is fine
if( me.serviceableN.getBoolValue() == 0 ) {
# if the inidcator failed before, re-enable it
print( me.baseNodeName ~ " is functional again" );
me.serviceableN.setBoolValue( 1 );
}
} else {
# pitot is iced
if( me.serviceableN.getBoolValue() != 0 ) {
# if the indicator was servicable before, fail it now
print( me.baseNodeName ~ " is failing" );
me.serviceableN.setBoolValue( 0 );
}
}
};
# Fail pitot at 0.03" of ice
PitotIcingHandler.new( 0, 0.03 );
var pitot_timer = maketimer(0.2, update_pitotIcing);

View file

@ -1,276 +1,148 @@
#############################################################################
# This file is part of FlightGear, the free flight simulator
# http://www.flightgear.org/
#
# Copyright (C) 2009 Torsten Dreyer, Torsten (at) t3r _dot_ de
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#############################################################################
##################################
# Icing Model for the A320Family #
# Code by Jonathan Redpath #
##################################
#########################################################################################
# this are the helper functions to model structural icing on airplanes
# Maintainer: Torsten Dreyer (Torsten at t3r dot de)
#
# Simple model: we listen to temperature and dewpoint. If the difference (spread)
# is near zero and temperature is below zero, icing may occour.
#
# inputs
# /environment/dewpoint-degc
# /environment/temperature-degc
# /environment/effective-visibility-m
# /velocities/airspeed-kt
# /environment/icing/max-spread-degc default: 0.1
#
# outputs
# /environment/icing/icing-severity numeric value of icing severity
# /environment/icing/icing-severity-name textual representation of icing severity one of
# none,trace,light,moderate,severe
# /environment/icing/icing-factor ammound of ice accumulation per NAM
#########################################################################
# implementation of the global icemachine
#########################################################################
var ICING_NONE = 0;
var ICING_TRACE = 1;
var ICING_LIGHT = 2;
var ICING_MODERATE = 3;
var ICING_SEVERE = 4;
# these are the names for the icing severities
var ICING_CATEGORY = [ "none", "trace", "light", "moderate", "severe" ];
# the ice accumulating factors. Inches per nautical air mile flown
var ICING_FACTOR = [
# none: sublimating 0.3" / 80NM
-0.3/80,
# traces: 0.5" / 80NM
0.5/80.0,
# light: 0.5" / 40NM
0.5/40.0,
# moderate: 0.5" / 20NM
0.5/20.0,
#severe: 0.5" / 10NM
0.5/10
];
# since we don't know the LWC of our clouds, just define some severities
# depending on temperature and a random offset
# format: upper temperatur, lower temperatur, minimum severity, maximum severity
var ICING_TEMPERATURE = [
[ 999, 0, ICING_NONE, ICING_NONE ],
[ 0, -2, ICING_NONE, ICING_MODERATE ],
[ -2, -12, ICING_LIGHT, ICING_SEVERE ],
[ -12, -20, ICING_LIGHT, ICING_MODERATE ],
[ -20, -30, ICING_TRACE, ICING_LIGHT ],
[ -30, -99, ICING_TRACE, ICING_NONE ]
];
var dewpointN = props.globals.getNode( "/environment/dewpoint-degc" );
var temperatureN = props.globals.getNode( "/environment/temperature-degc" );
var speedN = props.globals.getNode( "/velocities/airspeed-kt" );
var icingRootN = props.globals.getNode( "/environment/icing", 1 );
var visibilityN = props.globals.getNode( "/environment/effective-visibility-m" );
var severityN = icingRootN.initNode( "icing-severity", ICING_NONE, "INT" );
var severityNameN = icingRootN.initNode( "icing-severity-name", ICING_CATEGORY[severityN.getValue()] );
var icingFactorN = icingRootN.initNode( "icing-factor", 0.0 );
var maxSpreadN = icingRootN.initNode( "max-spread-degc", 0.1 );
var setSeverity = func {
var value = arg[0];
if( severityN.getValue() != value ) {
severityN.setValue( value );
severityNameN.setValue( ICING_CATEGORY[value] );
}
var icingInit = func {
setprop("/systems/icing/severity", "0"); # maximum severity: we will make it random
setprop("/systems/icing/factor", 0.0); # the factor is how many inches we add per second
setprop("/systems/icing/max-spread-degc", 0.0);
setprop("/systems/icing/icingcond", 0);
setprop("/controls/switches/windowprobeheat", 0);
setprop("/controls/switches/windowprobeheatfault", 0);
icing_timer.start();
}
#########################################################################################
# These are objects that are subject to icing
# inputs under /sim/model/icing/iceable (multiple instances allowed)
# ./name # name of this object, more or less useless
# ./salvage-control # name of a boolean property that salvages from ice
# ./output-property # the name of the property where the ice amount is written to
# ./sensitivity # a multiplier for the ice accumulation
#
# outputs
# ./ice-inches # the amount of ice in inches OR
# [property named by output-property] # the amount of ice in inches
#########################################################################################
var IceSensitiveElement = {};
var icingModel = func {
var dewpoint = getprop("/environment/dewpoint-degc");
var temperature = getprop("/environment/temperature-degc");
var speed = getprop("/velocities/airspeed-kt");
var visibility = getprop("/environment/effective-visibility-m");
var severity = getprop("/systems/icing/severity");
var factor = getprop("/systems/icing/factor");
var maxSpread = getprop("/systems/icing/max-spread-degc");
var icingCond = getprop("/systems/icing/icingcond");
IceSensitiveElement.new = func {
var obj = {};
obj.parents = [IceSensitiveElement];
obj.node = arg[0];
obj.nameN = obj.node.initNode( "name", "noname" );
var n = obj.node.getNode( "salvage-control", 0 );
obj.controlN = nil;
if( n != nil ) {
n = n.getValue();
if( n != nil ) {
obj.controlN = props.globals.initNode( n, 0, "BOOL" );
}
}
obj.sensitivityN = obj.node.initNode( "sensitivity", 1.0 );
obj.iceAmountN = nil;
n = obj.node.getNode( "output-property", 0 );
if( n != nil ) {
n = n.getValue();
if( n != nil ) {
obj.iceAmountN = props.globals.initNode( n, 0.0 );
}
}
if( obj.iceAmountN == nil ) {
obj.iceAmountN = obj.node.initNode( "ice-inches", 0.0 );
}
return obj;
};
#####################################################################
# this gets called from the icemachine on each update cycle
# arg[0] is the time in seconds since last update
# arg[1] is the number of NAM traveled since last update
# arg[2] is the ice-accumulation-factor for the current severity
#####################################################################
IceSensitiveElement.update = func {
if( me.controlN != nil and me.controlN.getBoolValue() ) {
if( me.iceAmountN.getValue() != 0.0 ) {
me.iceAmountN.setDoubleValue( 0.0 );
}
return;
}
var deltat = arg[0];
var dist_nm = arg[1];
var factor = arg[2];
var v = me.iceAmountN.getValue() + dist_nm * factor * me.sensitivityN.getValue();
if( v < 0.0 ) {
v = 0.0;
}
if( me.iceAmountN.getValue() != v ) {
me.iceAmountN.setValue( v );
}
};
#####################################################################
# read the ice sensitive elements from the config file
#####################################################################
var iceSensitiveElements = nil;
var icingConfigN = props.globals.getNode( "/sim/model/icing", 0 );
if( icingConfigN != nil ) {
iceSensitiveElements = [];
var iceableNodes = icingConfigN.getChildren( "iceable" );
foreach( var iceable; iceableNodes ) {
append( iceSensitiveElements, IceSensitiveElement.new( iceable ) );
}
};
#####################################################################
# the time triggered loop
#####################################################################
var elapsedTimeNode = props.globals.getNode( "/sim/time/elapsed-sec" );
var lastUpdate = 0.0;
var icing = func {
var temperature = temperatureN.getValue();
var severity = ICING_NONE;
icingFactorN.setDoubleValue( ICING_FACTOR[severity] );
var visibility = 0;
if( visibilityN != nil ) {
visibility = visibilityN.getValue();
}
# check if we should create some ice
var spread = temperature - dewpointN.getValue();
if( spread < maxSpreadN.getValue() and visibility < 1000 ) {
for( var i = 0; i < size(ICING_TEMPERATURE); i = i + 1 ) {
if( ICING_TEMPERATURE[i][0] > temperature and
ICING_TEMPERATURE[i][1] <= temperature ) {
var s1 = ICING_TEMPERATURE[i][2];
var s2 = ICING_TEMPERATURE[i][3];
var ds = s2 - s1 + 1;
severity = s1 + int(rand()*ds);
icingFactorN.setDoubleValue( ICING_FACTOR[severity] );
break;
}
}
} else {
# clear air
# melt ice if above freezing temperature
# the warmer, the faster. Lets guess that at 10degc
# 0.5 inch goes in 10miles
if( temperature > 0.0 ) {
icingFactorN.setDoubleValue( factor = -0.05 * temperature / 10.0 );
}
# if temperature below zero, sublimating factor is initialized
}
setSeverity( severity );
# update all sensitive areas
var now = elapsedTimeNode.getValue();
var dt = now - lastUpdate;
foreach( var iceable; iceSensitiveElements ) {
iceable.update( dt, dt * speedN.getValue()/3600.0, icingFactorN.getValue() );
}
lastUpdate = now;
settimer( icing, 2 );
}
#####################################################################
# start our icemachine
# don't care if there is nothing to put ice on
#####################################################################
if( iceSensitiveElements != nil ) {
lastUpdate = elapsedTimeNode.getValue();
icing();
}
#####################################################################
# OHP button
#####################################################################
setprop("/controls/switches/windowprobeheat", 0);
setprop("/controls/switches/windowprobeheatfault", 0);
setlistener("/controls/switches/windowprobeheat", func {
var windowprb = getprop("/controls/switches/windowprobeheat");
var fault = getprop("/controls/switches/windowprobeheatfault");
if (windowprb == 0.5) { # if in auto
var wowl = getprop("/gear/gear[1]/wow");
var wowr = getprop("/gear/gear[2]/wow");
var stateL = getprop("/engines/engine[0]/state");
var stateR = getprop("/engines/engine[1]/state");
var fault = getprop("/controls/switches/windowprobeheatfault");
if (!wowl or !wowr and !fault) {
setprop("/controls/deice/windowprobeheat", 1);
} else if (stateL == 3 or stateR == 3 and !fault) {
setprop("/controls/deice/windowprobeheat", 1);
}
} else if (windowprb == 1 and !fault) { # if in ON
setprop("/controls/deice/windowprobeheat", 1);
} else if (fault) {
setprop("/controls/deice/windowprobeheat", 0);
} else {
setprop("/controls/deice/windowprobeheat", 0);
if (severity == "0") {
setprop("/systems/icing/factor", -0.00000166);
} else if (severity == "1") {
setprop("/systems/icing/factor", 0.00000277);
} else if (severity == "2") {
setprop("/systems/icing/factor", 0.00000277);
} else if (severity == "3") {
setprop("/systems/icing/factor", 0.00000554);
} else if (severity == "4") {
setprop("/systems/icing/factor", 0.00001108);
} else if (severity == "5") {
setprop("/systems/icing/factor", 0.00002216);
}
});
#####################################################################
if (temperature >= 0 or !icingCond) {
setprop("/systems/icing/severity", "0");
} else if (temperature < 0 and temperature >= -2 and icingCond) {
setprop("/systems/icing/severity", "1");
} else if (temperature < -2 and temperature >= -12 and icingCond) {
setprop("/systems/icing/severity", "3");
} else if (temperature < -12 and temperature >= -30 and icingCond) {
setprop("/systems/icing/severity", "5");
} else if (temperature < -30 and temperature >= -40 and icingCond) {
setprop("/systems/icing/severity", "3");
} else if (temperature < -40 and temperature >= -99 and icingCond) {
setprop("/systems/icing/severity", "1");
}
var icing1 = getprop("/sim/model/icing/iceable[0]/ice-inches");
var sensitive1 = getprop("/sim/model/icing/iceable[0]/sensitivity");
var v = icing1 + (factor * sensitive1);
if (icing1 < 0.0) {
setprop("/sim/model/icing/iceable[0]/ice-inches", 0.0);
} else {
setprop("/sim/model/icing/iceable[0]/ice-inches", v);
}
var icing2 = getprop("/sim/model/icing/iceable[1]/ice-inches");
var sensitive2 = getprop("/sim/model/icing/iceable[1]/sensitivity");
var u = icing2 + (factor * sensitive2);
if (icing2 < 0.0) {
setprop("/sim/model/icing/iceable[1]/ice-inches", 0.0);
} else {
setprop("/sim/model/icing/iceable[1]/ice-inches", u);
}
var icing3 = getprop("/sim/model/icing/iceable[2]/ice-inches");
var sensitive3 = getprop("/sim/model/icing/iceable[2]/sensitivity");
var t = icing3 + (factor * sensitive3);
if (icing3 < 0.0) {
setprop("/sim/model/icing/iceable[2]/ice-inches", 0.0);
} else {
setprop("/sim/model/icing/iceable[2]/ice-inches", t);
}
var icing4 = getprop("/sim/model/icing/iceable[3]/ice-inches");
var sensitive4 = getprop("/sim/model/icing/iceable[3]/sensitivity");
var s = icing4 + (factor * sensitive4);
if (icing4 < 0.0) {
setprop("/sim/model/icing/iceable[3]/ice-inches", 0.0);
} else {
setprop("/sim/model/icing/iceable[3]/ice-inches", s);
}
var icing5 = getprop("/sim/model/icing/iceable[4]/ice-inches");
var sensitive5 = getprop("/sim/model/icing/iceable[4]/sensitivity");
var r = icing5 + (factor * sensitive5);
if (icing5 < 0.0) {
setprop("/sim/model/icing/iceable[4]/ice-inches", 0.0);
} else {
setprop("/sim/model/icing/iceable[4]/ice-inches", r);
}
var icing6 = getprop("/sim/model/icing/iceable[5]/ice-inches");
var sensitive6 = getprop("/sim/model/icing/iceable[5]/sensitivity");
var q = icing6 + (factor * sensitive6);
if (icing6 < 0.0) {
setprop("/sim/model/icing/iceable[5]/ice-inches", 0.0);
} else {
setprop("/sim/model/icing/iceable[5]/ice-inches", q);
}
# Do we create ice?
var spread = temperature - dewpoint;
if((spread < maxSpread and temperature < 0) or (temperature < 0 and visibility < 1000)) { # freezing fog or low temp and below dp
setprop("/systems/icing/icingcond", 1);
} else {
setprop("/systems/icing/icingcond", 0);
}
setlistener("/controls/switches/windowprobeheat", func {
var windowprb = getprop("/controls/switches/windowprobeheat");
var fault = getprop("/controls/switches/windowprobeheatfault");
if (windowprb == 0.5) { # if in auto
var wowl = getprop("/gear/gear[1]/wow");
var wowr = getprop("/gear/gear[2]/wow");
var stateL = getprop("/engines/engine[0]/state");
var stateR = getprop("/engines/engine[1]/state");
var fault = getprop("/controls/switches/windowprobeheatfault");
if (!wowl or !wowr and !fault) {
setprop("/controls/deice/windowprobeheat", 1);
} else if (stateL == 3 or stateR == 3 and !fault) {
setprop("/controls/deice/windowprobeheat", 1);
}
} else if (windowprb == 1 and !fault) { # if in ON
setprop("/controls/deice/windowprobeheat", 1);
} else if (fault) {
setprop("/controls/deice/windowprobeheat", 0);
} else {
setprop("/controls/deice/windowprobeheat", 0);
}
});
}
###################
# Update Function #
###################
var update_Icing = func {
icingModel();
}
var icing_timer = maketimer(0.2, update_Icing);

View file

@ -186,6 +186,8 @@ setlistener("/sim/signals/fdm-initialized", func {
fmgc.FMGCinit();
mcdu1.MCDU_init();
mcdu2.MCDU_init();
icing.PitotIcingReset();
icing.icingInit();
var autopilot = gui.Dialog.new("sim/gui/dialogs/autopilot/dialog", "Aircraft/A320Family/Systems/autopilot-dlg.xml");
setprop("/it-autoflight/input/fd1", 1);
setprop("/it-autoflight/input/fd2", 1);

View file

@ -53,6 +53,8 @@ var pneu_init = func {
setprop("/systems/ventilation/lavatory/extractvalve", "0");
setprop("/systems/pressurization/ambientpsi", "0");
setprop("/systems/pressurization/cabinpsi", "0");
setprop("/controls/deice/eng1-on", 0);
setprop("/controls/deice/eng2-on", 0);
pneu_timer.start();
}
@ -83,6 +85,8 @@ var master_pneu = func {
var bleedeng2_fail = getprop("/systems/failures/bleed-eng2");
var pack1_fail = getprop("/systems/failures/pack1");
var pack2_fail = getprop("/systems/failures/pack2");
var engantiice1 = getprop("/controls/deice/eng1-on");
var engantiice2 = getprop("/controls/deice/eng2-on");
# Air Sources/PSI
if (rpmapu >= 94.9 and bleedapu_sw and !bleedapu_fail) {
@ -153,6 +157,52 @@ var master_pneu = func {
setprop("/systems/pneumatic/groundair", 0);
}
if (engantiice1 and bleed1 > 20) { # shut down anti-ice if bleed is lost else turn it on
setprop("/controls/deice/lengine", 0);
setprop("/controls/deice/eng1-on", 0);
}
if (engantiice1) { # else turn it on
setprop("/controls/deice/lengine", 1);
}
if (engantiice2 and bleed2 > 20) {
setprop("/controls/deice/rengine", 0);
setprop("/controls/deice/eng2-on", 0);
}
if (engantiice2) {
setprop("/controls/deice/rengine", 1);
}
var flashfault1 = func {
setprop("/controls/deice/eng1-fault", 1);
settimer(func {
setprop("/controls/deice/eng1-fault", 0);
}, 0.5);
}
var flashfault2 = func {
setprop("/controls/deice/eng2-fault", 1);
settimer(func {
setprop("/controls/deice/eng2-fault", 0);
}, 0.5);
}
setlistener("/controls/deice/eng1-on", func {
var eng1on = getprop("/controls/deice/eng1-on");
if (eng1on) {
flashfault1();
}
});
setlistener("/controls/deice/eng2-on", func {
var eng2on = getprop("/controls/deice/eng2-on");
if (eng2on) {
flashfault2();
}
});
var total_psi = getprop("/systems/pneumatic/total-psi");
var phase = getprop("/FMGC/status/phase");

View file

@ -1,50 +0,0 @@
<PropertyList>
<sim>
<model>
<icing>
<iceable>
<name>Wing</name>
<salvage-control>/controls/deice/surface-deice-wingtail-light</salvage-control>
<sensitivity type="double">0.8</sensitivity>
<output-property>/fdm/jsbsim/ice/wing</output-property>
</iceable>
<iceable>
<name>Stabilizer</name>
<salvage-control>/controls/deice/surface-deice-wingtail-light</salvage-control>
<sensitivity type="double">1.0</sensitivity>
<output-property>/fdm/jsbsim/ice/stabilizer</output-property>
</iceable>
<iceable>
<name>LeftEngine</name>
<salvage-control>/controls/deice/prop-deice</salvage-control>
<sensitivity type="double">0.5</sensitivity>
<output-property>/fdm/jsbsim/ice/propeller</output-property>
</iceable>
<iceable>
<name>Right</name>Engine</name>
<salvage-control>/controls/deice/prop-deice</salvage-control>
<sensitivity type="double">0.5</sensitivity>
<output-property>/fdm/jsbsim/ice/propeller</output-property>
</iceable>
<iceable>
<name>Windshield</name>
<salvage-control>/controls/deice/windshield-deice</salvage-control>
<sensitivity type="double">0.5</sensitivity>
<!-- not relevant for fdm, ignore output-property -->
</iceable>
<iceable>
<name>Fuselage</name>
<!-- no salvage control, no deicing of the fuselage -->
<sensitivity type="double">0.3</sensitivity>
<output-property>/fdm/jsbsim/ice/fuselage</output-property>
</iceable>
<iceable>
<name>Pitot tube</name>
<sensitivity type="double">1</sensitivity>
<salvage-control>/controls/anti-ice/pitot-heat</salvage-control>
<output-property>/systems/pitot/icing</output-property>
</iceable>
</icing>
</model>
</sim>
</PropertyList>