hi,
Another round of cleaning, less properties spawned every where,
a few bugs corrected, cosmetics.
attached are:
A-10-20070511.diff
A-10-fuel.nas (goes in A-10/Nasal repertory)
to be removed from CVS:
A-10/Nasal/aar.nas
thanks,
Alexis
# Properties under /consumables/fuel/tank[n]:
# + level-gal_us - Current fuel load. Can be set by user code.
# + level-lbs - OUTPUT ONLY property, do not try to set
# + selected - boolean indicating tank selection.
# + density-ppg - Fuel density, in lbs/gallon.
# + capacity-gal_us - Tank capacity
#
# Properties under /engines/engine[n]:
# + fuel-consumed-lbs - Output from the FDM, zeroed by this script
# + out-of-fuel - boolean, set by this code.
var UPDATE_PERIOD = 0.3;
var enabled = nil;
var fuel_freeze = nil;
var ai_enabled = nil;
var engines = nil;
var tanks = nil;
var refuelingN = nil;
var aimodelsN = nil;
var out_of_fuel = nil;
var aar_rcvr = nil;
var aar_lock = nil;
var aar_state = nil;
# initialize property if it doesn't exist, and set node type otherwise
init_prop = func(node, prop, val, type = "double") {
var n = node.getNode(prop);
if (n != nil) {
var v = n.getValue();
if (v != nil) {
val = v;
}
}
node = node.getNode(prop, 1);
if (type == "double") {
node.setDoubleValue(val);
} elsif (type == "bool") {
node.setBoolValue(val);
} elsif (type == "int") {
node.setIntValue(val);
}
}
update_loop = func {
# check for contact with tanker aircraft
var tankers = [];
if (ai_enabled) {
foreach (a; aimodelsN.getChildren("aircraft")) {
var contact =
a.getNode("refuel/contact").getBoolValue();
var tanker = a.getNode("tanker").getBoolValue();
#var id = a.getNode("id").getValue();
#print("ai '", id, "' contact=", contact, " tanker=",
tanker);
if (tanker and contact) {
append(tankers, a);
}
}
foreach (m; aimodelsN.getChildren("multiplayer")) {
var contact =
m.getNode("refuel/contact").getBoolValue();
var tanker = m.getNode("tanker").getBoolValue();
#var id = m.getNode("id").getValue();
#print("mp '", id, "' contact=", contact, " tanker=",
tanker);
if (tanker and contact) {
append(tankers, m);
}
}
}
# A-10 specific receiver logic
var refueling = size(tankers) >= 1;
refuelingN.setBoolValue(refueling);
if (size(tankers) >= 1) {
if ((! aar_lock) and (aar_rcvr)) {
refueling = 1;
aar_state = 1;
} else {
refueling = 0;
}
} elsif (aar_state) {
aar_lock = 1;
setprop("sim/model/A-10/controls/fuel/aar-lock", aar_lock);
aar_state = 0;
}
if (fuel_freeze) {
return settimer(update_loop, UPDATE_PERIOD);
}
# sum up consumed fuel
var total = 0;
foreach (var e; engines) {
total += e.getNode("fuel-consumed-lbs").getValue();
e.getNode("fuel-consumed-lbs", 1).setDoubleValue(0);
}
# unlock A-10 aar receiver lock and calculate fuel received
if (refueling) {
# assume max flow rate is 6000 lbs/min (for KC135)
var received = 100 * UPDATE_PERIOD;
total -= received;
}
# make list of selected tanks
var selected_tanks = [];
foreach (var t; tanks) {
var cap = t.getNode("capacity-gal_us", 1).getValue();
if (cap != nil and cap > 0.01 and t.getNode("selected",
1).getBoolValue()) {
append(selected_tanks, t);
}
}
if (size(selected_tanks) == 0) {
out_of_fuel = 1;
} else {
out_of_fuel = 0;
if (total >= 0) {
var fuelPerTank = total / size(selected_tanks);
foreach (var t; selected_tanks) {
var ppg = t.getNode("density-ppg").getValue();
var lbs = t.getNode("level-gal_us").getValue()
* ppg;
lbs -= fuelPerTank;
if (lbs < 0) {
lbs = 0;
# Kill the engines if we're told to,
otherwise simply
# deselect the tank.
if (t.getNode("kill-when-empty",
1).getBoolValue()) {
out_of_fuel = 1;
} else {
t.getNode("selected",
1).setBoolValue(0);
}
}
var gals = lbs / ppg;
t.getNode("level-gal_us").setDoubleValue(gals);
t.getNode("level-lbs").setDoubleValue(lbs);
}
} elsif (total < 0) {
#find the number of tanks which can accept fuel
var available = 0;
foreach (var t; selected_tanks) {
var ppg = t.getNode("density-ppg").getValue();
var capacity =
t.getNode("capacity-gal_us").getValue() * ppg;
var lbs = t.getNode("level-gal_us").getValue()
* ppg;
if (lbs < capacity) {
available += 1;
}
}
if (available > 0) {
var fuelPerTank = total / available;
# add fuel to each available tank
foreach (var t; selected_tanks) {
var ppg =
t.getNode("density-ppg").getValue();
var capacity =
t.getNode("capacity-gal_us").getValue() * ppg;
var lbs =
t.getNode("level-gal_us").getValue() * ppg;
if (capacity - lbs >= fuelPerTank) {
lbs -= fuelPerTank;
} elsif (capacity - lbs < fuelPerTank) {
lbs = capacity;
}
t.getNode("level-gal_us").setDoubleValue(lbs / ppg);
t.getNode("level-lbs").setDoubleValue(lbs);
}
# print ("available ", available , "
fuelPerTank " , fuelPerTank);
}
}
}
var gals = 0;
var lbs = 0;
var cap = 0;
foreach (var t; tanks) {
gals += t.getNode("level-gal_us", 1).getValue();
lbs += t.getNode("level-lbs", 1).getValue();
cap += t.getNode("capacity-gal_us", 1).getValue();
}
setprop("/consumables/fuel/total-fuel-gals", gals);
setprop("/consumables/fuel/total-fuel-lbs", lbs);
setprop("/consumables/fuel/total-fuel-norm", gals / cap);
# prepare values for the A-10's fuel gauge and warning lights
left_wing = getprop("consumables/fuel/tank[0]/level-lbs");
left_main = getprop("consumables/fuel/tank[1]/level-lbs");
right_main = getprop("consumables/fuel/tank[2]/level-lbs");
right_wing = getprop("consumables/fuel/tank[3]/level-lbs");
total_int_left = left_wing + left_main;
total_int_right = right_wing + right_main;
setprop("sim/model/A-10/consumables/fuel/int-left-lbs", total_int_left);
setprop("sim/model/A-10/consumables/fuel/int-right-lbs",
total_int_right);
diff_lbs = abs(right_main - left_main);
setprop("sim/model/A-10/consumables/fuel/diff-lbs", diff_lbs);
# stop the A-10's engines when off or when out of fuel
foreach (var i; [0,1]) {
running = getprop("sim/model/A-10/engines/engine["~ i ~
"]/running");
if (! running) {
setprop("engines/engine["~ i ~ "]/out-of-fuel", 1);
} else {
setprop("engines/engine["~ i ~ "]/out-of-fuel",
out_of_fuel);
}
}
# miscelaneous A-10's props
setprop("velocities/ground-speed-kt", ground_speed());
settimer(update_loop, UPDATE_PERIOD);
}
initialize = func {
fuel.update = func {} # kill $FG_ROOT/Nasal/fuel.nas' loop
print ("Initializing Nasal Fuel System");
refuelingN = props.globals.getNode("/systems/refuel/contact", 1);
refuelingN.setBoolValue(0);
aar_rcvr = getprop("sim/model/A-10/controls/fuel/receiver-lever");
aar_lock = getprop("sim/model/A-10/controls/fuel/aar-lock");
aar_state = 0;
aimodelsN = props.globals.getNode("ai/models", 1);
engines = props.globals.getNode("engines", 1).getChildren("engine");
tanks = props.globals.getNode("consumables/fuel",
1).getChildren("tank");
foreach (var e; engines) {
e.getNode("fuel-consumed-lbs", 1).setDoubleValue(0);
e.getNode("out-of-fuel", 1).setBoolValue(0);
}
foreach (var t; tanks) {
init_prop(t, "level-gal_us", 0);
init_prop(t, "level-lbs", 0);
init_prop(t, "capacity-gal_us", 0.01); # Not zero (div/zero
issue)
init_prop(t, "density-ppg", 6.0); # gasoline
init_prop(t, "selected", 1, "bool");
}
setlistener("sim/freeze/fuel", func { fuel_freeze =
cmdarg().getBoolValue() }, 1);
setlistener("sim/ai/enabled", func { ai_enabled =
cmdarg().getBoolValue() }, 1);
}
ground_speed = func {
nfps = getprop("velocities/speed-north-fps");
efps = getprop("velocities/speed-east-fps");
vfps = math.sqrt((nfps * nfps) + (efps * efps));
# 1 kph = 1 fps / 6080.27 * 3600
vkph = vfps * 0.59207897;
return(vkph);
}
aar_receiver_lever = func {
input = arg[0];
aar_rcvr = getprop("sim/model/A-10/controls/fuel/receiver-lever");
if (input == 1) {
aar_rcvr = 1;
setprop("sim/model/A-10/controls/fuel/receiver-lever",
aar_rcvr);
} elsif (input == -1) {
aar_rcvr = 0;
setprop("sim/model/A-10/controls/fuel/receiver-lever",
aar_rcvr);
aar_lock = 0;
setprop("sim/model/A-10/controls/fuel/aar-lock", aar_lock);
}
}
#aar_receiver_lever = func {
# input = arg[0];
# aar_rcvr = getprop("sim/model/A-10/controls/fuel/receiver-lever");
# if ((input == 1) and (aar_rcvr == 0)) {
# aar_rcvr = 1;
# setprop("sim/model/A-10/controls/fuel/receiver-lever", aar_rcvr)
# } elsif ((input == -1) and (aar_rcvr == 1)) {
# aar_rcvr = 0;
# setprop("sim/model/A-10/controls/fuel/receiver-lever", aar_rcvr)
# }
#}
wait_for_fdm = func {
if (getprop("/position/altitude-agl-ft")) { # is there a better
indicator?
initialize();
update_loop();
} else {
settimer(wait_for_fdm, 1);
}
}
settimer(wait_for_fdm, 0);
Index: A-10.nas
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Nasal/A-10.nas,v
retrieving revision 1.15
diff -u -p -r1.15 A-10.nas
--- A-10.nas 4 May 2007 15:52:59 -0000 1.15
+++ A-10.nas 11 May 2007 19:07:02 -0000
@@ -427,20 +427,10 @@ zero_ext_tanks_sub = func {
setprop("consumables/fuel/tank[6]/selected", "false");
}
#--------------------------------------------------------------------
- toggle_traj_mkr = func {
- if(getprop("/ai/submodels/trajectory-markers") == nil) {
- setprop("/ai/submodels/trajectory-markers", 0);
- }
- if(getprop("/ai/submodels/trajectory-markers") < 1) {
- setprop("/ai/submodels/trajectory-markers", 1);
- } else {
- setprop("/ai/submodels/trajectory-markers", 0);
- }
+var toggle_traj_mkr = func {
+ var p = "/ai/submodels/trajectory-markers";
+ setprop(p, !getprop(p));
}
-
- #--------------------------------------------------------------------
-
-
#--------------------------------------------------------------------
initialise_drop_view_pos = func {
eyelatdeg = getprop("position/latitude-deg");
@@ -485,16 +475,20 @@ start_up = func {
settimer(ap_common_elevator_monitor, 0.5);
settimer(altimeter_monitor, 0.5);
}
-#--------------------------------------------------------------------
+
+# HUD ---------------------------------------------------------------
+setlistener("/sim/current-view/view-number", func {
+ setprop("/sim/hud/visibility[1]", cmdarg().getValue() == 0);
+}, 1);
# strobes -----------------------------------------------------------
strobe_switch = props.globals.getNode("controls/lighting/strobe", 1);
aircraft.light.new("sim/model/A-10/lighting/strobe", [0.05, 1.00],
strobe_switch);
# nav lights -----------------------------------------------------------
-nav_lights_switch =
props.globals.getNode("controls/A-10/lighting/nav-lights-flash", 1);
+nav_lights_switch =
props.globals.getNode("sim/model/A-10/controls/lighting/nav-lights-flash", 1);
aircraft.light.new("sim/model/A-10/lighting/nav-lights", [0.62, 0.62],
nav_lights_switch);
# warning lights medium speed
-----------------------------------------------------------
-warn_medium_lights_switch =
props.globals.getNode("controls/A-10/lighting/warn-medium-lights-switch", 1);
+warn_medium_lights_switch =
props.globals.getNode("sim/model/A-10/controls/lighting/warn-medium-lights-switch",
1);
aircraft.light.new("sim/model/A-10/lighting/warn-medium-lights", [0.40, 0.30],
warn_medium_lights_switch);
Index: electrical.nas
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Nasal/electrical.nas,v
retrieving revision 1.2
diff -u -p -r1.2 electrical.nas
--- electrical.nas 5 Dec 2006 20:55:43 -0000 1.2
+++ electrical.nas 11 May 2007 19:07:02 -0000
@@ -36,7 +36,7 @@ init_electrical = func {
setprop("systems/electrical/R-conv-volts", 0.0);
setprop("systems/electrical/inverter-volts", 0.0);
setprop("systems/electrical/radar", 24.0);
- # radar only used to allow Air to Air Refueling to work.
+ # radar only used to allow Air to Air Refueling to work.
settimer(update_electrical, 0);
}
@@ -86,18 +86,33 @@ AlternatorClass.new = func {
}
AlternatorClass.apply_load = func( amps, dt, src ) {
rpm = getprop(src);
- factor = math.ln(rpm)/4;
+ # A-10 APU can have 0 rpm
+ if (rpm == 0) {
+ factor = 0;
+ } else {
+ factor = math.ln(rpm)/4;
+ }
available_amps = me.ideal_amps * factor;
return available_amps - amps;
}
AlternatorClass.get_output_volts = func( src ) {
rpm = getprop(src );
- factor = math.ln(rpm)/4;
+ # A-10 APU can have 0 rpm
+ if (rpm == 0) {
+ factor = 0;
+ } else {
+ factor = math.ln(rpm)/4;
+ }
return me.ideal_volts * factor;
}
AlternatorClass.get_output_amps = func(src ){
rpm = getprop( src );
- factor = math.ln(rpm)/4;
+ # A-10 APU can have 0 rpm
+ if (rpm == 0) {
+ factor = 0;
+ } else {
+ factor = math.ln(rpm)/4;
+ }
return me.ideal_amps * factor;
}
@@ -115,6 +130,8 @@ update_electrical = func {
update_virtual_bus = func( dt ) {
+ eng_outof = getprop("engines/engine[0]/out-of-fuel");
+ eng_outof1 = getprop("engines/engine[1]/out-of-fuel");
master_bat = getprop("controls/electric/battery-switch");
master_apu = getprop("controls/electric/APU-generator[0]");
master_alt = getprop("controls/electric/engine[0]/generator");
@@ -122,10 +139,10 @@ update_virtual_bus = func( dt ) {
master_inv = getprop("sim/model/A-10/controls/switches/inverter");
external_volts = 0.0;
battery_volts = battery.get_output_volts();
- if (master_alt) {
+ if (master_alt and !eng_outof) {
L_gen_volts = alternator.get_output_volts("engines/engine[0]/n1");
} else { L_gen_volts = 0.0;}
- if (master_alt1) {
+ if (master_alt1 and !eng_outof1) {
R_gen_volts = alternator.get_output_volts("engines/engine[1]/n1");
} else { R_gen_volts = 0.0; }
if (master_apu) {
@@ -142,58 +159,58 @@ update_virtual_bus = func( dt ) {
if (APU_gen_volts >= 23) {
R_conv_volts = APU_gen_volts;
if ((L_gen_volts < 23) and (R_gen_volts < 23)) {
- L_AC_bus_volts = APU_gen_volts;
- R_AC_bus_volts = APU_gen_volts;
- AC_ESSEN_bus_volts = APU_gen_volts;
- L_conv_volts = APU_gen_volts;
+ L_AC_bus_volts = APU_gen_volts;
+ R_AC_bus_volts = APU_gen_volts;
+ AC_ESSEN_bus_volts = APU_gen_volts;
+ L_conv_volts = APU_gen_volts;
}
if ((L_gen_volts < 23) and (R_gen_volts >= 23)) {
- L_AC_bus_volts = R_gen_volts;
- R_AC_bus_volts = R_gen_volts;
- AC_ESSEN_bus_volts = R_gen_volts;
- L_conv_volts = R_gen_volts;
+ L_AC_bus_volts = R_gen_volts;
+ R_AC_bus_volts = R_gen_volts;
+ AC_ESSEN_bus_volts = R_gen_volts;
+ L_conv_volts = R_gen_volts;
}
if ((L_gen_volts >= 23) and (R_gen_volts < 23)) {
- L_AC_bus_volts = L_gen_volts;
- R_AC_bus_volts = L_gen_volts;
- AC_ESSEN_bus_volts = L_gen_volts;
- L_conv_volts = L_gen_volts;
+ L_AC_bus_volts = L_gen_volts;
+ R_AC_bus_volts = L_gen_volts;
+ AC_ESSEN_bus_volts = L_gen_volts;
+ L_conv_volts = L_gen_volts;
}
if ((L_gen_volts >= 23) and (R_gen_volts >= 23)) {
- L_AC_bus_volts = L_gen_volts;
- R_AC_bus_volts = R_gen_volts;
- AC_ESSEN_bus_volts = L_gen_volts;
- L_conv_volts = L_gen_volts;
+ L_AC_bus_volts = L_gen_volts;
+ R_AC_bus_volts = R_gen_volts;
+ AC_ESSEN_bus_volts = L_gen_volts;
+ L_conv_volts = L_gen_volts;
}
}
if (APU_gen_volts < 23) {
if ((L_gen_volts < 23) and (R_gen_volts < 23)) {
- L_AC_bus_volts = 0.0;
- R_AC_bus_volts = 0.0;
- AC_ESSEN_bus_volts = INV_volts;
- L_conv_volts = 0.0;
- R_conv_volts = 0.0;
+ L_AC_bus_volts = 0.0;
+ R_AC_bus_volts = 0.0;
+ AC_ESSEN_bus_volts = INV_volts;
+ L_conv_volts = 0.0;
+ R_conv_volts = 0.0;
}
if ((L_gen_volts < 23) and (R_gen_volts >= 23)) {
- L_AC_bus_volts = R_gen_volts;
- R_AC_bus_volts = R_gen_volts;
- AC_ESSEN_bus_volts = R_gen_volts;
- L_conv_volts = R_gen_volts;
- R_conv_volts = R_gen_volts;
+ L_AC_bus_volts = R_gen_volts;
+ R_AC_bus_volts = R_gen_volts;
+ AC_ESSEN_bus_volts = R_gen_volts;
+ L_conv_volts = R_gen_volts;
+ R_conv_volts = R_gen_volts;
}
if ((L_gen_volts >= 23) and (R_gen_volts < 23)) {
- L_AC_bus_volts = L_gen_volts;
- R_AC_bus_volts = L_gen_volts;
- AC_ESSEN_bus_volts = L_gen_volts;
- L_conv_volts = L_gen_volts;
- R_conv_volts = L_gen_volts;
+ L_AC_bus_volts = L_gen_volts;
+ R_AC_bus_volts = L_gen_volts;
+ AC_ESSEN_bus_volts = L_gen_volts;
+ L_conv_volts = L_gen_volts;
+ R_conv_volts = L_gen_volts;
}
if ((L_gen_volts >= 23) and (R_gen_volts >= 23)) {
- L_AC_bus_volts = L_gen_volts;
- R_AC_bus_volts = R_gen_volts;
- AC_ESSEN_bus_volts = L_gen_volts;
- L_conv_volts = L_gen_volts;
- R_conv_volts = L_gen_volts;
+ L_AC_bus_volts = L_gen_volts;
+ R_AC_bus_volts = R_gen_volts;
+ AC_ESSEN_bus_volts = L_gen_volts;
+ L_conv_volts = L_gen_volts;
+ R_conv_volts = L_gen_volts;
}
}
@@ -246,21 +263,7 @@ update_virtual_bus = func( dt ) {
power_source = "battery";
}
-# # left starter motor
-# starter_switch = getprop("controls/engines/engine[0]/starter");
-# starter_volts = 0.0;
-# if ( starter_switch ) {
-# starter_volts = bat_src_volts;
-# }
-# setprop("systems/electrical/outputs/starter[0]", starter_volts);
-
-# # right starter motor
-# starter_switch = getprop("controls/engines/engine[1]/starter");
-# starter_volts = 0.0;
-# if ( starter_switch ) {
-# starter_volts = bat_src_volts;
-# }
-# setprop("systems/electrical/outputs/starter[1]", starter_volts);
+
load += BATT_bus();
@@ -304,11 +307,6 @@ update_virtual_bus = func( dt ) {
}
-# if ( getprop("controls/switches/pitot-heat" ) ) {
-# setprop("systems/electrical/outputs/pitot-heat", battery_bus_volts);
-# } else {
-# setprop("systems/electrical/outputs/pitot-heat", 0.0);
-# }
BATT_bus = func() {
@@ -377,7 +375,8 @@ AC_ESSEN_bus = func() {
return load;
}
-settimer(init_electrical, 0);
+setlistener("/sim/signals/fdm-initialized", init_electrical);
+
@@ -385,69 +384,69 @@ settimer(init_electrical, 0);
# -------------------------------
inverter_switch = func {
- input = arg[0];
- if (input == 1) {
- inverter_switch_up();
- } else {
- inverter_switch_down();
- }
-}
-
-inverter_switch_up = func {
- if (getprop("sim/model/A-10/controls/switches/inverter") == 0) {
- setprop("sim/model/A-10/controls/switches/inverter", 1);
- } elsif (getprop("sim/model/A-10/controls/switches/inverter") == 1) {
- setprop("sim/model/A-10/controls/switches/inverter", 2);
- }
-}
-inverter_switch_down = func {
- if (getprop("sim/model/A-10/controls/switches/inverter") == 2) {
- setprop("sim/model/A-10/controls/switches/inverter", 1);
- } elsif (getprop("sim/model/A-10/controls/switches/inverter") == 1) {
- setprop("sim/model/A-10/controls/switches/inverter", 0);
- }
+ inv_pos =
props.globals.getNode("sim/model/A-10/controls/switches/inverter", 1);
+ pos = inv.getValue();
+ input = arg[0];
+ if ( input == 1 ) {
+ if ( pos == 0 ) {
+ inv_pos.setIntValue(1);
+ } elsif ( pos == 1 ) {
+ inv_pos.setIntValue(2);
+ }
+ } else {
+ if ( pos == 2 ) {
+ inv_pos.setIntValue(1);
+ } elsif ( pos == 1 ) {
+ inv_pos.setIntValue(0);
+ }
+ }
}
+
+
# lighting controls
# -----------------
nav_lights_switcher = func {
- input = arg[0];
- if (input == 1) { nav_lights_switch_up() } else { nav_lights_switch_down() }
-}
-nav_lights_switch_up = func {
- if (getprop("controls/A-10/lighting/nav-lights-switch") == 0) {
- setprop("controls/A-10/lighting/nav-lights-switch", 1);
- } elsif (getprop("controls/A-10/lighting/nav-lights-switch") == 1) {
- setprop("controls/A-10/lighting/nav-lights-switch", 2);
- setprop("controls/A-10/lighting/nav-lights-flash", 1);
- }
-}
-nav_lights_switch_down = func {
- if (getprop("controls/A-10/lighting/nav-lights-switch") == 2) {
- setprop("controls/A-10/lighting/nav-lights-switch", 1);
- setprop("controls/A-10/lighting/nav-lights-flash", 0);
- } elsif (getprop("controls/A-10/lighting/nav-lights-switch") == 1) {
- setprop("controls/A-10/lighting/nav-lights-switch", 0);
- }
+ flash =
props.globals.getNode("sim/model/A-10/controls/lighting/nav-lights-flash", 1);
+ s_pos =
props.globals.getNode("sim/model/A-10/controls/lighting/nav-lights-switch", 1);
+ pos = s_pos.getValue();
+ input = arg[0];
+ if ( input == 1 ) {
+ if ( pos == 0 ) {
+ s_pos.setIntValue(1);
+ } elsif ( pos == 1 ) {
+ s_pos.setIntValue(2);
+ s_pos.setBoolValue(1);
+ }
+ } else {
+ if ( pos == 2 ) {
+ s_pos.setIntValue(1);
+ flash.setBoolValue(0);
+ } elsif ( pos == 1 ) {
+ s_pos.setIntValue(0);
+ }
+ }
}
+
+
land_lights_switcher = func {
- input = arg[0];
- if (input == 1) { land_lights_switch_up() } else { land_lights_switch_down()
}
-}
-land_lights_switch_up = func {
- if (getprop("controls/A-10/lighting/land-lights-switch") == 0) {
- setprop("controls/A-10/lighting/land-lights-switch", 1);
- } elsif (getprop("controls/A-10/lighting/land-lights-switch") == 1) {
- setprop("controls/A-10/lighting/land-lights-switch", 2);
- }
-}
-land_lights_switch_down = func {
- if (getprop("controls/A-10/lighting/land-lights-switch") == 2) {
- setprop("controls/A-10/lighting/land-lights-switch", 1);
- } elsif (getprop("controls/A-10/lighting/land-lights-switch") == 1) {
- setprop("controls/A-10/lighting/land-lights-switch", 0);
- }
+ s_pos =
props.globals.getNode("sim/model/A-10/controls/lighting/land-lights-switch", 1);
+ pos = s_pos.getValue();
+ input = arg[0];
+ if ( input == 1 ) {
+ if ( pos == 0 ) {
+ s_pos.setIntValue(1);
+ } elsif ( pos == 1 ) {
+ s_pos.setIntValue(2);
+ }
+ } else {
+ if ( pos == 2 ) {
+ s_pos.setIntValue(1);
+ } elsif ( pos == 1 ) {
+ s_pos.setIntValue(0);
+ }
+ }
}
Index: landing_gear_handle.nas
===================================================================
RCS file:
/var/cvs/FlightGear-0.9/data/Aircraft/A-10/Nasal/landing_gear_handle.nas,v
retrieving revision 1.2
diff -u -p -r1.2 landing_gear_handle.nas
--- landing_gear_handle.nas 26 Jun 2006 18:15:41 -0000 1.2
+++ landing_gear_handle.nas 11 May 2007 19:07:02 -0000
@@ -3,35 +3,37 @@
setlistener( "controls/gear/gear-down", func {ldg_hdl_main();} );
+ld_hdl =
props.globals.getNode("sim/model/A-10/controls/gear/ld-gear-handle-anim", 1);
+
ldg_hdl_main = func {
+ pos = ld_hdl.getValue();
if ( getprop("controls/gear/gear-down") == 1 ) {
- if ( getprop("controls/gear/A-10-landing-gear-hdl-anim") > -1 ) {
- ldg_hdl_anim(-1); # move it down
+ if ( pos > -1 ) {
+ ldg_hdl_anim(-1, pos);
}
} else {
- if ( getprop("controls/gear/A-10-landing-gear-hdl-anim") < 0 ) {
- ldg_hdl_anim(1); # move it up
- }
+ if ( pos < 0 ) {
+ ldg_hdl_anim(1, pos);
+ }
}
}
ldg_hdl_anim = func {
- ldg_hdl_anim_anim = getprop("controls/gear/A-10-landing-gear-hdl-anim");
+
incr = arg[0]/10;
- ldg_hdl_anim_anim = ldg_hdl_anim_anim + incr;
+ pos = arg[1] + incr;
+
+ if (( arg[0] = 1 ) and ( pos >= 0 )){
+ ld_hdl.setDoubleValue(0);
+
+ } elsif (( arg[0] = -1 ) and ( pos <= -1 )){
+ ld_hdl.setDoubleValue(-1);
- # stop anim when handle up
- if (( arg[0] = 1 ) and ( ldg_hdl_anim_anim >= 0 )){
- setprop("controls/gear/A-10-landing-gear-hdl-anim", 0);
- # stop anim when handle down
- } elsif (( arg[0] = -1 ) and ( ldg_hdl_anim_anim <= -1 )){
- setprop("controls/gear/A-10-landing-gear-hdl-anim", -1);
-
- # continue anim
} else {
- setprop("controls/gear/A-10-landing-gear-hdl-anim", ldg_hdl_anim_anim);
+ ld_hdl.setDoubleValue(pos);
settimer( ldg_hdl_main, 0.05 );
+
}
}
Index: pilot-g.nas
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Nasal/pilot-g.nas,v
retrieving revision 1.3
diff -u -p -r1.3 pilot-g.nas
--- pilot-g.nas 5 Dec 2006 20:55:43 -0000 1.3
+++ pilot-g.nas 11 May 2007 19:07:02 -0000
@@ -9,7 +9,7 @@ registerTimer = func {
pilot_g = props.globals.getNode("accelerations/pilot-g", 1);
timeratio = props.globals.getNode("accelerations/timeratio",
1);
pilot_g_damped =
props.globals.getNode("accelerations/pilot-g-damped", 1);
- hud_intens_control = props.globals.getNode("controls/A-10/hud/intens",
1);
+ hud_intens_control =
props.globals.getNode("sim/model/A-10/controls/hud/intens", 1);
hud_alpha = props.globals.getNode("sim[0]/hud/color/alpha", 1);
hud_volts =
props.globals.getNode("systems/electrical/outputs/hud", 1);
@@ -31,8 +31,9 @@ update_pilot_g = func {
damp = (g * n) + (damp * (1 - n));
pilot_g_damped.setDoubleValue(damp);
-# their should be an electrical param for hud, like other instruments,
-# so dealing here with power alimentation is a dirty workaround.
+
+ # there should be an electrical param for hud, like other instruments,
+ # so dealing here with power alimentation is a dirty workaround.
if (hvolts > 24) {
if (damp > 3) {
if (damp > 5) {
Index: A-10-panel-r3.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Models/A-10-panel-r3.xml,v
retrieving revision 1.3
diff -u -p -r1.3 A-10-panel-r3.xml
--- A-10-panel-r3.xml 5 Dec 2006 20:55:42 -0000 1.3
+++ A-10-panel-r3.xml 11 May 2007 19:17:33 -0000
@@ -27,7 +27,7 @@
<animation>
<object-name>nav-flash-switch</object-name>
<type>rotate</type>
- <property>controls/A-10/lighting/nav-lights-switch</property>
+ <property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<interpolation>
<entry><ind>0</ind><dep>-30</dep></entry>
<entry><ind>1</ind><dep>0</dep></entry>
Index: A-10-panel-r3-hotspot.xml
===================================================================
RCS file:
/var/cvs/FlightGear-0.9/data/Aircraft/A-10/Models/A-10-panel-r3-hotspot.xml,v
retrieving revision 1.3
diff -u -p -r1.3 A-10-panel-r3-hotspot.xml
--- A-10-panel-r3-hotspot.xml 5 Dec 2006 20:55:42 -0000 1.3
+++ A-10-panel-r3-hotspot.xml 11 May 2007 19:17:33 -0000
@@ -101,7 +101,7 @@
<h>65</h>
<binding>
<command>property-adjust</command>
- <property>controls/A-10/lighting/formation</property>
+ <property>sim/model/A-10/controls/lighting/formation</property>
<step>0.1</step>
<max>1.0</max>
</binding>
@@ -116,7 +116,7 @@
<h>65</h>
<binding>
<command>property-adjust</command>
- <property>controls/A-10/lighting/formation</property>
+ <property>sim/model/A-10/controls/lighting/formation</property>
<step>-0.1</step>
<min>0.0</min>
</binding>
Index: A-10-ld-gear-panel.xml
===================================================================
RCS file:
/var/cvs/FlightGear-0.9/data/Aircraft/A-10/Models/A-10-ld-gear-panel.xml,v
retrieving revision 1.3
diff -u -p -r1.3 A-10-ld-gear-panel.xml
--- A-10-ld-gear-panel.xml 5 Dec 2006 20:55:42 -0000 1.3
+++ A-10-ld-gear-panel.xml 11 May 2007 19:17:33 -0000
@@ -8,7 +8,7 @@
<name>flaps</name>
<type>rotate</type>
<object-name>needle</object-name>
- <property>surface-positions/left-flap-pos-norm</property>
+ <property>surface-positions/left-flap-pos-norm</property>
<interpolation>
<entry><ind>0</ind><dep>0</dep></entry>
<entry><ind>0.333</ind><dep>30</dep></entry>
@@ -120,7 +120,7 @@
<name>ld-gear-handle</name>
<type>rotate</type>
<object-name>ld-gear-handle</object-name>
- <property>controls/gear/A-10-landing-gear-hdl-anim</property>
+ <property>sim/model/A-10/controls/gear/ld-gear-handle-anim</property>
<factor>52</factor>
<center>
<x-m>-0.0121</x-m>
@@ -139,7 +139,7 @@
<animation>
<object-name>light-land-switch</object-name>
<type>rotate</type>
- <property>controls/A-10/lighting/land-lights-switch</property>
+ <property>sim/model/A-10/controls/lighting/land-lights-switch</property>
<interpolation>
<entry><ind>0</ind><dep>-30</dep></entry>
<entry><ind>1</ind><dep>0</dep></entry>
Index: A-10-model.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Models/A-10-model.xml,v
retrieving revision 1.12
diff -u -p -r1.12 A-10-model.xml
--- A-10-model.xml 10 May 2007 20:25:07 -0000 1.12
+++ A-10-model.xml 11 May 2007 19:17:36 -0000
@@ -2311,10 +2311,10 @@
<or>
<and>
<property>sim/model/A-10/lighting/nav-lights/state</property>
-
<property>controls/A-10/lighting/nav-lights-flash</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-flash</property>
</and>
<equals>
-
<property>controls/A-10/lighting/nav-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<value>0</value>
</equals>
</or>
@@ -2368,10 +2368,10 @@
<or>
<and>
<property>sim/model/A-10/lighting/nav-lights/state</property>
-
<property>controls/A-10/lighting/nav-lights-flash</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-flash</property>
</and>
<equals>
-
<property>controls/A-10/lighting/nav-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<value>0</value>
</equals>
</or>
@@ -2424,10 +2424,10 @@
<or>
<and>
<property>sim/model/A-10/lighting/nav-lights/state</property>
-
<property>controls/A-10/lighting/nav-lights-flash</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-flash</property>
</and>
<equals>
-
<property>controls/A-10/lighting/nav-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<value>0</value>
</equals>
</or>
@@ -2486,7 +2486,7 @@
</equals>
<not>
<equals>
-
<property>controls/A-10/lighting/land-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/land-lights-switch</property>
<value>1</value>
</equals>
</not>
@@ -2539,7 +2539,7 @@
<value>1</value>
</equals>
<equals>
-
<property>controls/A-10/lighting/land-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/land-lights-switch</property>
<value>2</value>
</equals>
</condition>
@@ -2591,7 +2591,7 @@
<object-name>noshadow.TailEmpL-Formation</object-name>
<type>material</type>
<emission>
-
<factor-prop>controls/A-10/lighting/formation</factor-prop>
+
<factor-prop>sim/model/A-10/controls/lighting/formation</factor-prop>
<red>0.91</red>
<green>0.98</green>
<blue>0.78</blue>
Index: A-10-hud.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Models/A-10-hud.xml,v
retrieving revision 1.3
diff -u -p -r1.3 A-10-hud.xml
--- A-10-hud.xml 5 Dec 2006 20:55:41 -0000 1.3
+++ A-10-hud.xml 11 May 2007 19:17:36 -0000
@@ -8,7 +8,7 @@
<animation>
<type>translate</type>
<object-name>gun-cross</object-name>
- <property>controls/A-10/hud/depr</property>
+ <property>sim/model/A-10/controls/hud/depr</property>
<factor>0.03</factor>
<axis>
<x>0.00</x>
@@ -23,7 +23,7 @@
<object-name>gun-cross</object-name>
<type>material</type>
<emission>
- <factor-prop>controls/A-10/hud/intens</factor-prop>
+ <factor-prop>sim/model/A-10/controls/hud/intens</factor-prop>
<red>0.5</red>
<green>1.0</green>
<blue>0.5</blue>
Index: A-10-panel-L-hotspot.xml
===================================================================
RCS file:
/var/cvs/FlightGear-0.9/data/Aircraft/A-10/Models/A-10-panel-L-hotspot.xml,v
retrieving revision 1.4
diff -u -p -r1.4 A-10-panel-L-hotspot.xml
--- A-10-panel-L-hotspot.xml 11 Jan 2007 12:54:47 -0000 1.4
+++ A-10-panel-L-hotspot.xml 11 May 2007 19:17:37 -0000
@@ -57,7 +57,7 @@
<h>30</h>
<binding>
<command>property-adjust</command>
- <property>controls/A-10/hud/depr</property>
+ <property>sim/model/A-10/controls/hud/depr</property>
<step>-0.05</step>
<min>-1.0</min>
<max>1.0</max>
@@ -73,7 +73,7 @@
<h>30</h>
<binding>
<command>property-adjust</command>
- <property>controls/A-10/hud/depr</property>
+ <property>sim/model/A-10/controls/hud/depr</property>
<step>0.05</step>
<min>-1.0</min>
<max>1.0</max>
@@ -91,7 +91,7 @@
<h>30</h>
<binding>
<command>property-adjust</command>
- <property>controls/A-10/hud/intens</property>
+ <property>sim/model/A-10/controls/hud/intens</property>
<step>-0.1</step>
<min>0.0</min>
<max>1.0</max>
@@ -107,7 +107,7 @@
<h>30</h>
<binding>
<command>property-adjust</command>
- <property>controls/A-10/hud/intens</property>
+ <property>sim/model/A-10/controls/hud/intens</property>
<step>0.1</step>
<min>0.0</min>
<max>1.0</max>
Index: A-10-sound.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Aircraft/A-10/Sounds/A-10-sound.xml,v
retrieving revision 1.5
diff -u -p -r1.5 A-10-sound.xml
--- A-10-sound.xml 11 Jan 2007 12:54:49 -0000 1.5
+++ A-10-sound.xml 11 May 2007 19:19:56 -0000
@@ -10,18 +10,21 @@
<path>Sounds/jet.wav</path>
<mode>looped</mode>
<condition>
- <or>
- <not>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- </not>
- <greater-than>
- <property>canopy/position-norm</property>
+ <or>
+ <not>
+ <equals>
+ <property>sim/current-view/view-number</property>
<value>0</value>
- </greater-than>
- </or>
+ </equals>
+ </not>
+ <greater-than>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </greater-than>
+ </or>
+ <not>
+ <property>engines/engine[0]/out-of-fuel</property>
+ </not>
</condition>
<volume>
<property>engines/engine[0]/prop-thrust</property>
@@ -38,18 +41,21 @@
<path>Sounds/whine.wav</path>
<mode>looped</mode>
<condition>
- <or>
- <not>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- </not>
- <greater-than>
- <property>canopy/position-norm</property>
+ <or>
+ <not>
+ <equals>
+ <property>sim/current-view/view-number</property>
<value>0</value>
- </greater-than>
- </or>
+ </equals>
+ </not>
+ <greater-than>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </greater-than>
+ </or>
+ <not>
+ <property>engines/engine[0]/out-of-fuel</property>
+ </not>
</condition>
<volume>
<property>engines/engine[0]/n2</property>
@@ -67,18 +73,21 @@
<path>Sounds/jet.wav</path>
<mode>looped</mode>
<condition>
- <or>
- <not>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- </not>
- <greater-than>
- <property>canopy/position-norm</property>
+ <or>
+ <not>
+ <equals>
+ <property>sim/current-view/view-number</property>
<value>0</value>
- </greater-than>
- </or>
+ </equals>
+ </not>
+ <greater-than>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </greater-than>
+ </or>
+ <not>
+ <property>engines/engine[1]/out-of-fuel</property>
+ </not>
</condition>
<volume>
<property>engines/engine[1]/prop-thrust</property>
@@ -95,18 +104,21 @@
<path>Sounds/whine.wav</path>
<mode>looped</mode>
<condition>
- <or>
- <not>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- </not>
- <greater-than>
- <property>canopy/position-norm</property>
+ <or>
+ <not>
+ <equals>
+ <property>sim/current-view/view-number</property>
<value>0</value>
- </greater-than>
- </or>
+ </equals>
+ </not>
+ <greater-than>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </greater-than>
+ </or>
+ <not>
+ <property>engines/engine[1]/out-of-fuel</property>
+ </not>
</condition>
<volume>
<property>engines/engine[1]/n2</property>
@@ -125,14 +137,17 @@
<path>Sounds/jet.wav</path>
<mode>looped</mode>
<condition>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- <less-than-equals>
- <property>canopy/position-norm</property>
- <value>0</value>
- </less-than-equals>
+ <equals>
+ <property>sim/current-view/view-number</property>
+ <value>0</value>
+ </equals>
+ <not>
+ <property>engines/engine[0]/out-of-fuel</property>
+ </not>
+ <less-than-equals>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </less-than-equals>
</condition>
<volume>
<property>engines/engine[0]/prop-thrust</property>
@@ -145,18 +160,21 @@
</engine-inside-0>
<whine-inside-1>
- <name>whine-inside-1</name>
+ <name>whine-inside-0</name>
<path>Sounds/whine.wav</path>
<mode>looped</mode>
<condition>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- <less-than-equals>
- <property>canopy/position-norm</property>
- <value>0</value>
- </less-than-equals>
+ <equals>
+ <property>sim/current-view/view-number</property>
+ <value>0</value>
+ </equals>
+ <not>
+ <property>engines/engine[0]/out-of-fuel</property>
+ </not>
+ <less-than-equals>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </less-than-equals>
</condition>
<volume>
<property>engines/engine[0]/n2</property>
@@ -174,14 +192,17 @@
<path>Sounds/jet.wav</path>
<mode>looped</mode>
<condition>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- <less-than-equals>
- <property>canopy/position-norm</property>
- <value>0</value>
- </less-than-equals>
+ <equals>
+ <property>sim/current-view/view-number</property>
+ <value>0</value>
+ </equals>
+ <not>
+ <property>engines/engine[1]/out-of-fuel</property>
+ </not>
+ <less-than-equals>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </less-than-equals>
</condition>
<volume>
<property>engines/engine[1]/prop-thrust</property>
@@ -198,14 +219,17 @@
<path>Sounds/whine.wav</path>
<mode>looped</mode>
<condition>
- <equals>
- <property>sim/current-view/view-number</property>
- <value>0</value>
- </equals>
- <less-than-equals>
- <property>canopy/position-norm</property>
- <value>0</value>
- </less-than-equals>
+ <equals>
+ <property>sim/current-view/view-number</property>
+ <value>0</value>
+ </equals>
+ <not>
+ <property>engines/engine[1]/out-of-fuel</property>
+ </not>
+ <less-than-equals>
+ <property>canopy/position-norm</property>
+ <value>0</value>
+ </less-than-equals>
</condition>
<volume>
<property>engines/engine[1]/n2</property>
@@ -1364,7 +1388,7 @@
<path>Aircraft/A-10/Sounds/click.wav</path>
<condition>
<equals>
- <property>controls/A-10/lighting/nav-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<value>2</value>
</equals>
</condition>
@@ -1378,7 +1402,7 @@
<path>Aircraft/A-10/Sounds/click.wav</path>
<condition>
<equals>
- <property>controls/A-10/lighting/nav-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<value>1</value>
</equals>
</condition>
@@ -1392,7 +1416,7 @@
<path>Aircraft/A-10/Sounds/click.wav</path>
<condition>
<equals>
- <property>controls/A-10/lighting/nav-lights-switch</property>
+
<property>sim/model/A-10/controls/lighting/nav-lights-switch</property>
<value>0</value>
</equals>
</condition>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel