1
0
Fork 0
fgdata/Aircraft/Instruments-3d/FG1000/GFC700-vertical-FSM.xml
Stuart Buchanan 9d353a3266 FG1000: GFC700 Autopilot Integration
Support for GFC700 autopilot.  Current modes that work: AP, FD, ROL, PIT, HDG, VS
2019-02-10 22:06:31 +00:00

374 lines
11 KiB
XML

<PropertyList>
<!-- GFC 700 Autopilot Finite State Machine for vertical mode. Also handles AP and FD toggling -->
<branch>/autopilot/GFC700/FSM/vertical</branch>
<state>
<name>OFF</name>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/altitude</property>
<value></value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode</property>
<value></value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-armed</property>
<value></value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-target</property>
<value></value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/speed</property>
<value></value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/passive-mode</property>
<value>1</value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<state>
<name>PIT</name>
<!-- Pitch hold mode. We assign a filtered value, which limits to to [-15.0, 20.0] -->
<enter>
<command>property-assign</command>
<property n="0">/autopilot/settings/target-pitch-deg</property>
<property n="1">/autopilot/internal/filtered-pitch-deg</property>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/altitude</property>
<value>pitch-hold</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode</property>
<value>PIT</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-target</property>
<value></value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<state>
<name>GA</name>
<!-- GA mode - 7 degree pitch up-->
<enter>
<command>property-assign</command>
<property n="0">/autopilot/settings/target-pitch-deg</property>
<value>7.0</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/altitude</property>
<value>pitch-hold</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode</property>
<value>GA</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-target</property>
<value></value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<state>
<name>VS</name>
<!-- VS mode -->
<enter>
<command>nasal</command>
<script>
<!-- Calculate the fpm value to the nearest 100fpm. -->
setprop("/autopilot/settings/vertical-speed-fpm",
math.round(getprop("/autopilot/internal/vert-speed-fpm"),100)
);
setprop("/autopilot/annunciator/vertical-mode-target",
sprintf("%+ifpm", getprop("/autopilot/settings/vertical-speed-fpm"))
);
</script>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/altitude</property>
<value>vertical-speed-hold</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode</property>
<value>VS</value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<state>
<name>ALTS-ARM</name>
<!-- Arm Altitude Capture Mode - ALTS -->
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-armed</property>
<value>ALTS</value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<transition>
<name>ALTS Capture</name>
<!-- Altitude Capture Mode enabled when we get within 500ft of the selected altitude -->
<source>ALTS-ARM</source>
<target>ALTS</target>
<condition>
<less-than>
<property>/autopilot/internal/target-altitude-delta-ft</property>
<value>500</value>
</less-than>
<greater-than>
<property>/autopilot/internal/target-altitude-delta-ft</property>
<value>-500</value>
</greater-than>
</condition>
</transition>
<state>
<name>ALTS</name>
<enter>
<command>nasal</command>
<script>
<!-- Set up the 2nd target, so that it is independent of the Selected Altitude,
then annunciator to the reference value current target value, then enable
the altitude capture function -->
setprop("/autopilot/settings/target-altitude-ft-2", getprop("/autopilot/settings/target-altitude-ft"));
setprop("/autopilot/annunciator/vertical-mode-target",
sprintf("%ift", getprop("/autopilot/settings/target-altitude-ft-2"))
);
</script>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode</property>
<value>ALTS</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-armed</property>
<value>ALT</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/altitude</property>
<value>altitude-hold2</value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<transition>
<!-- ALTS (Selected Altitude Capture) automatically armed from PIT, TO/GA, VS, VPTH, FLC modes -->
<name>ALTS-ARM</name>
<source>PIT</source>
<source>GA</source>
<source>VS</source>
<target>ALTS-ARM</target>
<!-- Transitions must have a condition element. So set it to True -->
<condition>
<not>
<property>/sim/time/elapsed-sec</property>
<value>0</value>
</not>
</condition>
</transition>
<transition>
<!-- Altitude Hold Mode enabled when we get within 50ft of the selected altitude -->
<name>ALTS-ALT</name>
<source>ALTS</source>
<target>ALT</target>
<condition>
<less-than>
<property>/autopilot/internal/ALTS-target-altitude-delta-ft</property>
<value>50</value>
</less-than>
<greater-than>
<property>/autopilot/internal/ALTS-target-altitude-delta-ft</property>
<value>-50</value>
</greater-than>
</condition>
</transition>
<state>
<name>ALT</name>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode</property>
<value>ALT</value>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/annunciator/vertical-mode-armed</property>
<value></value>
</enter>
<enter>
<command>nasal</command>
<script>
setprop("/autopilot/annunciator/vertical-mode-target",
sprintf("%ift", getprop("/autopilot/settings/target-altitude-ft-2"))
);
</script>
</enter>
<enter>
<command>property-assign</command>
<property>/autopilot/locks/altitude</property>
<value>altitude-hold2</value>
</enter>
<enter>
<!-- Reset button to avoid triggering next transition immediately -->
<command>property-assign</command>
<property>/autopilot/vertical-mode-button</property>
<value></value>
</enter>
</state>
<!-- From the OFF state, pressing any of FD, AP, CWS, NAV, BC, APR, HDG changes to PIT mode -->
<transition>
<name>OFF-PIT</name>
<source>OFF</source>
<target>PIT</target>
<exclude-target>true</exclude-target>
<condition>
<or>
<equals><property>/autopilot/vertical-mode-button</property><value>AP</value></equals>
<equals><property>/autopilot/vertical-mode-button</property><value>FD</value></equals>
<equals><property>/autopilot/vertical-mode-button</property><value>CWS</value></equals>
<equals><property>/autopilot/vertical-mode-button</property><value>NAV</value></equals>
<equals><property>/autopilot/vertical-mode-button</property><value>BC</value></equals>
<equals><property>/autopilot/vertical-mode-button</property><value>APR</value></equals>
<equals><property>/autopilot/vertical-mode-button</property><value>HDG</value></equals>
</or>
</condition>
</transition>
<!-- From most vertical modes, pressing the mode key again returns to PIT mode -->
<transition>
<name>VS-PIT</name>
<source>VS</source>
<target>PIT</target>
<condition>
<equals><property>/autopilot/vertical-mode-button</property><value>VS</value></equals>
</condition>
</transition>
<transition>
<name>GA-PIT</name>
<source>GA</source>
<target>PIT</target>
<condition>
<equals><property>/autopilot/vertical-mode-button</property><value>GA</value></equals>
</condition>
</transition>
<!-- AP/FD logic is somewhat complex:
1) Pressing AP toggles the autopilot on/off
Handled by a separate FSM. We could use a series of transitions
to the same states below, but that would result in entry bindings being repeated, which would be bad
2) When the AP is enabled, the FD button is disabled. (Easy - no transition!)
3) Pressing the FD button when the FD is enabled switches off the FD : Switch-off transition below
-->
<!-- From any state pressing FD when FD is ON switches off the FD -->
<transition>
<name>FD-Switch-off</name>
<target>OFF</target>
<exclude-target>true</exclude-target>
<condition>
<not><equals><property>/autopilot/annunciator/autopilot-enabled</property><value>1</value></equals></not>
<equals><property>/autopilot/vertical-mode-button</property><value>FD</value></equals>
<equals><property>/autopilot/locks/passive-mode</property><value>1</value></equals>
</condition>
</transition>
<!-- From any state pressing VS changes to VS mode -->
<transition>
<name>VS</name>
<target>VS</target>
<exclude-target>true</exclude-target>
<condition>
<equals><property>/autopilot/vertical-mode-button</property><value>VS</value></equals>
</condition>
</transition>
<!-- From any state, pressing GA goes to GA mode -->
<transition>
<name>GA</name>
<target>GA</target>
<exclude-target>true</exclude-target>
<condition>
<equals><property>/autopilot/vertical-mode-button</property><value>GA</value></equals>
</condition>
</transition>
<!-- From any state, pressing ALT goes to ALT mode -->
<transition>
<name>ALT</name>
<target>ALT</target>
<exclude-target>true</exclude-target>
<condition>
<equals><property>/autopilot/vertical-mode-button</property><value>ALT</value></equals>
</condition>
<binding>
<command>nasal</command>
<script>
<!-- Set up the 2nd target to the current altitude within 10ft-->
setprop("/autopilot/settings/target-altitude-ft-2",
math.round(getprop("/instrumentation/altimeter/indicated-altitude-ft"),10));
</script>
</binding>
</transition>
</PropertyList>