Skip to content

Commit

Permalink
State overlay support
Browse files Browse the repository at this point in the history
Add support for state overlays.
  • Loading branch information
Stuart Buchanan committed Dec 17, 2020
1 parent 78b1865 commit 4009cc7
Show file tree
Hide file tree
Showing 12 changed files with 378 additions and 157 deletions.
5 changes: 0 additions & 5 deletions Models/c172p.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5195,13 +5195,8 @@
<action>
<binding>
<command>property-adjust</command>
<<<<<<< HEAD
<property>controls/engines/current-engine/mixture</property>
<factor>0.02</factor>
=======
<property>controls/engines/engine[0]/mixture</property>
<factor>0.02</factor>
>>>>>>> Fix quadrants by removing active engines
<min>0</min>
<max>1</max>
<wrap>0</wrap>
Expand Down
8 changes: 0 additions & 8 deletions Nasal/avionics.nas
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ aircraft.data.add(
aircraft.data.add(
"/controls/anti-ice/engine/carb-heat",
"/controls/anti-ice/pitot-heat",
"/consumables/fuel/tank/selected",
"/consumables/fuel/tank[1]/selected",
"/sim/model/c172p/brake-parking",
"/controls/flight/flaps",
"/controls/flight/elevator-trim",
"/controls/engines/engine[0]/throttle",
"/controls/engines/engine[0]/mixture",
"/controls/engines/engine[0]/primer-lever",
);

# Circuit breakers
Expand Down
15 changes: 3 additions & 12 deletions Nasal/c172p.nas
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
##########################################

var autostart = func (msg=1) {
screen.log.write("Autostart", 1.0, 1.0, 0.8);
if (getprop("/engines/engine[0]/running")) {
if (msg)
gui.popupTip("Engine already running", 5);
Expand All @@ -12,11 +13,10 @@ var autostart = func (msg=1) {
# Reset battery charge and circuit breakers
electrical.reset_battery_and_circuit_breakers();

# Filling fuel tanks
# Set fuel tanks
setprop("/consumables/fuel/tank[0]/selected", 1);
setprop("/consumables/fuel/tank[1]/selected", 1);

# Setting levers and switches for startup
setprop("/controls/switches/magnetos", 3);
setprop("/controls/engines/engine[0]/throttle", 0.2);

Expand Down Expand Up @@ -54,9 +54,6 @@ var autostart = func (msg=1) {
}
}

# Setting flaps to 0
setprop("/controls/flight/flaps", 0.0);

# Set the altimeter
var pressure_sea_level = getprop("/environment/pressure-sea-level-inhg");
setprop("/instrumentation/altimeter/setting-inhg", pressure_sea_level);
Expand All @@ -67,7 +64,6 @@ var autostart = func (msg=1) {

# Pre-flight inspection
setprop("/sim/model/c172p/cockpit/control-lock-placed", 0);
setprop("/sim/model/c172p/brake-parking", 0);
setprop("/sim/model/c172p/securing/chock", 0);
setprop("/sim/model/c172p/securing/cowl-plugs-visible", 0);
setprop("/sim/model/c172p/securing/pitot-cover-visible", 0);
Expand Down Expand Up @@ -616,7 +612,7 @@ setlistener("/sim/signals/fdm-initialized", func {
# Use Nasal to make some properties persistent. <aircraft-data> does
# not work reliably.
aircraft.data.add("/sim/model/c172p/immat-on-panel");
aircraft.data.load();
#aircraft.data.load();

# Initialize mass limits
set_limits(props.globals.getNode("/controls/engines/engine[0]"));
Expand Down Expand Up @@ -664,11 +660,6 @@ setlistener("/sim/signals/fdm-initialized", func {

reset_system();

var onground = getprop("/sim/presets/onground") or "";
if (!onground) {
state_manager();
}

# set user defined pilot view or initialize it
settimer(func {
if (getprop("sim/current-view/user/x-offset-m") != nil){
Expand Down
1 change: 1 addition & 0 deletions Nasal/state-manager.nas
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

var state_manager = func {

screen.log.write("state_manager statrting engine", 0.8, 0.8, 0.8);
if (!getprop("/sim/presets/airspeed-kt")) {
setprop("/velocities/airspeed-kt", 100);
setprop("/velocities/uBody-fps", 163);
Expand Down
59 changes: 0 additions & 59 deletions Systems/engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,65 +80,6 @@
</output>
</filter>

<!-- ============================================================== -->
<!-- Starter -->
<!-- ============================================================== -->

<logic>
<name>Engine Starter</name>
<input>
<property>/controls/engines/engine[0]/starter</property>
</input>
<output>
<property>/controls/engines/engine[0]/starter</property>
</output>
</logic>

<!-- ============================================================== -->
<!-- Throttle -->
<!-- ============================================================== -->

<filter>
<name>Engine Throttle</name>
<type>gain</type>
<input>
<property>/controls/engines/engine[0]/throttle</property>
</input>
<output>
<property>/controls/engines/engine[0]/throttle</property>
</output>
</filter>

<!-- ============================================================== -->
<!-- Mixture -->
<!-- ============================================================== -->

<filter>
<name>Engine Mixture</name>
<type>gain</type>
<input>
<property>/controls/engines/engine[0]/mixture</property>
</input>
<output>
<property>/controls/engines/engine[0]/mixture</property>
</output>
</filter>

<!-- ============================================================== -->
<!-- Carburetor Heat -->
<!-- ============================================================== -->

<filter>
<name>Engine Carb Heat</name>
<type>gain</type>
<input>
<property>/controls/engines/engine[0]/carb-heat</property>
</input>
<output>
<property>/controls/anti-ice/engine[0]/carb-heat</property>
</output>
</filter>

<!-- ============================================================== -->
<!-- Fuel contamination and low oil level -->
<!-- ============================================================== -->
Expand Down
28 changes: 5 additions & 23 deletions c172p-set.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,36 +280,21 @@ http://forum.flightgear.org/viewtopic.php?f=4&t=25157
<aircraft-data>
<path>/sim/rendering/shadow-volume</path>
<path>/sim/model/occupants</path>
<path>/sim/model/c172p/cockpit/control-lock-placed</path>
<path>/sim/model/c172p/securing/pitot-cover-visible</path>
<path>/sim/model/c172p/securing/cowl-plugs-visible</path>
<path>/sim/model/c172p/securing/chock</path>
<path>/sim/model/c172p/securing/tiedownL-visible</path>
<path>/sim/model/c172p/securing/tiedownR-visible</path>
<path>/sim/model/c172p/securing/tiedownT-visible</path>
<path>/sim/model/c172p/brake-parking</path>
<path>/sim/model/c172p/enable-fog-frost</path>
<path>/sim/model/c172p/garmin196-visible</path>
<path>/sim/model/c172p/digitalclock-visible</path>
<path>/engines/engine[0]/carb_icing_allowed</path>
<path>/engines/engine[0]/oil_consumption_allowed</path>
<path>/engines/engine[0]/oil-service-hours</path>
<path>/engines/engine[0]/oil-level</path>
<path>/fdm/jsbsim/engine/damage-level</path>
<path>/fdm/jsbsim/settings/damage</path>
<path>/fdm/jsbsim/settings/damage-flag</path>
<path>/environment/aircraft-effects/cabin-heat-set</path>
<path>/environment/aircraft-effects/cabin-air-set</path>
<path>/controls/climate-control/overhead-vent-front-left</path>
<path>/controls/climate-control/overhead-vent-front-right</path>
<path>/fdm/jsbsim/running</path>
<path>/consumables/fuel/save-fuel-state</path>
<path>/consumables/fuel/contamination_allowed</path>
<path>/instrumentation/save-switches-state</path>
<path>/consumables/fuel/tank[0]/level-gal_us</path>
<path>/consumables/fuel/tank[1]/level-gal_us</path>
<path>/systems/electrical/save-battery-charge</path>
<path>/systems/electrical/battery-charge-percent</path>
<path>/sim/model/c172p/save-state</path>
<path>/engines/engine[0]/complex-engine-procedures</path>
<path>/sim/model/immat</path>
Expand Down Expand Up @@ -578,7 +563,10 @@ http://forum.flightgear.org/viewtopic.php?f=4&t=25157
</dialogs>
</gui>

<state include="states/c172p-automatic-overlay.xml" n="0"/>
<state include="states/parked-overlay.xml" n="0"/>
<state include="states/take-off-overlay.xml" n="1"/>
<state include="states/cruise-overlay.xml" n="2"/>
<state include="states/approach-overlay.xml" n="3"/>

</sim>

Expand All @@ -600,7 +588,7 @@ http://forum.flightgear.org/viewtopic.php?f=4&t=25157
<engine n="0">
<primer type="double">0</primer>
<primer-lever type="bool">false</primer-lever>
<throttle type="double">0.0</throttle>
<!-- <throttle type="double">0.0</throttle> -->
<mixture type="double">0.0</mixture>
<use-primer type="bool">false</use-primer>
</engine>
Expand Down Expand Up @@ -708,12 +696,6 @@ http://forum.flightgear.org/viewtopic.php?f=4&t=25157
<selected type="bool">true</selected>
<hidden type="bool">true</hidden>
</tank>
<tank n="3">
<name>Float chamber 2</name>
<capacity unit="LBS"> 0.1 </capacity>
<selected type="bool">true</selected>
<hidden type="bool">true</hidden>
</tank>
<save-fuel-state type="bool">false</save-fuel-state>
<contamination_allowed type="bool">false</contamination_allowed>
</fuel>
Expand Down
10 changes: 0 additions & 10 deletions gui/dialogs/aircraft-dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@
<group>
<layout>vbox</layout>

<checkbox>
<halign>left</halign>
<label>Start with engine running</label>
<property>/fdm/jsbsim/running</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>

<checkbox>
<halign>left</halign>
<label>Save state of aircraft between sessions</label>
Expand Down
102 changes: 102 additions & 0 deletions states/approach-overlay.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<PropertyList>

<name type="string">approach</name>

<description>
The plane will be in "approach" state with engines running.
Initial Airspeed is set to 80 knots.
You should also set an --altitude=... setting to start in-air
and an offset position to a runway to practice approaches or use the launcher to set this up.

Start this state with --state=approach.
</description>

<overlay>
<controls>
<engines>
<engine n="0">
<throttle>0.6</throttle>
</engine>
</engines>
<flight>
<flaps>0.3333</flaps>
</flight>
</controls>
<sim>
<model>
<c172p>
<cockpit>
<control-lock-placed>false</control-lock-placed>
<control-lock-visible>false</control-lock-visible>
</cockpit>
<securing>
<pitot-cover-visible>false</pitot-cover-visible>
<cowl-plugs-visible>false</cowl-plugs-visible>
<chock>false</chock>
<tiedownL-visible>false</tiedownL-visible>
<tiedownR-visible>false</tiedownR-visible>
<tiedownT-visible>false</tiedownT-visible>
</securing>
<brake-parking>0</brake-parking>
<damage>
<left-wing>0</left-wing>
<right-wing>0</right-wing>
</damage>
<control-surfaces>
<elevator-checked type="bool">false</elevator-checked>
<left-aileron-checked type="bool">false</left-aileron-checked>
<right-aileron-checked type="bool">false</right-aileron-checked>
<rudder-checked type="bool">false</rudder-checked>
</control-surfaces>
</c172p>
</model>
<presets>
<speed-set type="string">knots</speed-set>
<airspeed-kt type="int">80</airspeed-kt>
<pitch-deg type="double">0</pitch-deg>
<roll-deg type="double">0</roll-deg>
<uBody-fps type="double">163</uBody-fps>
<vBody-fps type="double">0</vBody-fps>
<wBody-fps type="double">0</wBody-fps>
<glideslope-deg type="double">-3</glideslope-deg>
<trim type="bool">true</trim>
<onground type="bool">false</onground>
</presets>
</sim>
<engines>
<engine>
<oil-service-hours>100</oil-service-hours>
<oil-level>7.0</oil-level>
</engine>
</engines>
<fdm>
<jsbsim>
<engine>
<damage-level>0</damage-level>
</engine>
<settings>
<damage>0</damage>
<damage-flag>0</damage-flag>
</settings>
<running>1</running>
</jsbsim>
</fdm>
<consumables>
<fuel>
<tank n="0">
<level-gal_us>20</level-gal_us>
</tank>
<tank n="1">
<level-gal_us>20</level-gal_us>
</tank>
</fuel>
</consumables>
<systems>
<electrical>
<battery-charge-percent>100</battery-charge-percent>
</electrical>
</systems>
</overlay>
</PropertyList>
40 changes: 0 additions & 40 deletions states/c172p-automatic-overlay.xml

This file was deleted.

Loading

0 comments on commit 4009cc7

Please sign in to comment.