Add possibility to set max altitude in route dialog

This commit is contained in:
PlayeRom 2022-08-26 20:57:41 +02:00
parent bcd7d3cca8
commit ea72151d48
5 changed files with 83 additions and 21 deletions

View File

@ -59,13 +59,15 @@ Default route
This add-on add a new item to main menu named `Aerotow Everywhere` with following items:
1. `Aerotow Route` - display the dialog for change aerotow route.
2. `Call for Piper J3 Cub aircraft` - load AI tow sceneraio with Piper J3 Cub.
3. `Call for Robin DR400 aircraft` - load AI tow sceneraio with Robin DR400. This aircraft has better performance and can take you higher then Piper Cub.
4. `Call for Cessna 182 aircraft` - load AI tow sceneraio with Cessna 182. This aircraft has little bit better performance than Robin.
5. `Disable tow aircraft` - unload AI tow sceneraio.
6. `Add thermal` - display the dialog for configuring and adding thermal.
7. `Help` - display help dialog.
8. `About` - display about dialog with add-on information.
2. `Towrope Configuration` - display the dialog for change towrope parameters.
3. `Call for Piper J3 Cub aircraft` - load AI tow sceneraio with Piper J3 Cub.
4. `Call for Robin DR400 aircraft` - load AI tow sceneraio with Robin DR400. This aircraft has better performance and can take you higher then Piper Cub.
5. `Call for Cessna 182 aircraft` - load AI tow sceneraio with Cessna 182. This aircraft has little bit better performance than Robin.
6. `Call for Douglas C-47 aircraft` - load AI tow sceneraio with Douglas C-47.
7. `Disable tow aircraft` - unload AI tow sceneraio.
8. `Add thermal` - display the dialog for configuring and adding thermal.
9. `Help` - display help dialog.
10. `About` - display about dialog with add-on information.
## Aerotow Route
@ -75,6 +77,10 @@ You can change the AI aircraft's default route, for this go to menu `Aerotow Eve
On the top of the "Aerotow Route" dialog you have selector to change aircraft type. It's only for calculate performance and display how the altitude will change.
### Max alt (AGL)
Here you can set limit of AGL altitude. 0 means without limits - the plane will always increase its altitude during its flight. AGL is always in terms of the place you are starting from.
### Route
Next you have initial heading, distance and altitude change. "Initial heading" depend of the runway where you are located. The aircraft will always take-off along the runway, a distance of 100 m, where it will gain 20 ft in altitude above the terrain. These parameters you cannot change unless you change the airport/runway.
@ -83,7 +89,7 @@ Next you can see a table with fields where you can change values. Each row repre
1. `Heading change (deg)` - information on how the heading of the aircraft should change in relation to the previous one. A value of `0` means no change, so continue with the same heading. And e.g. `-90` means a left turn of 90 degrees, `60` means a right turn of 60 degrees, etc.
2. `Distance (m)` - distance in meters from the previous waypoint to the present one.
3. `Alt change (AGL ft)` - information on how much the altitude on this leg of the route will increase (in feet above ground.) This information depend of selected airplane.
3. `Alt change (AGL ft)` - information on how much the altitude on this leg of the route will increase (in feet above ground.) This information depend of selected airplane. AGL is always in terms of the place you are starting from (not the waypoint place).
If you enter a value less than or equal to `0` for `Distance (m)` field this means that here the route is end and the next rows will not be included to the flight plan.

View File

@ -44,6 +44,10 @@
<distance-m type="double">0</distance-m>
<alt-change-agl-ft type="double">0</alt-change-agl-ft>
</init-wpt>
<wpts>
<description type="string">Default route around the start location</description>
<max-alt-agl type="double"></max-alt-agl>
</wpts>
<total>
<distance>0</distance>
<alt>0</alt>

View File

@ -75,14 +75,14 @@
<row>0</row>
<col>0</col>
<halign>right</halign>
<label>Aerotow</label>
<label>Aerotow:</label>
</text>
<combo>
<row>0</row>
<col>1</col>
<halign>left</halign>
<pref-width>150</pref-width>
<pref-width>120</pref-width>
<live>true</live>
<property>/addons/by-id/org.flightgear.addons.Aerotow/addon-devel/route/ai-model</property>
<value>Piper J3 Cub</value>
@ -93,6 +93,24 @@
<command>dialog-apply</command>
</binding>
</combo>
<text>
<row>0</row>
<col>2</col>
<halign>right</halign>
<label>Max alt (AGL):</label>
</text>
<input>
<row>0</row>
<col>3</col>
<halign>left</halign>
<property>/addons/by-id/org.flightgear.addons.Aerotow/addon-devel/route/wpts/max-alt-agl</property>
<live>true</live>
<binding>
<command>dialog-apply</command>
</binding>
</input>
</group>
<hrule/>
@ -501,7 +519,7 @@
<input>
<halign>fill</halign>
<halign>left</halign>
<!-- <halign>left</halign> -->
<property>/addons/by-id/org.flightgear.addons.Aerotow/addon-devel/route/wpts/description</property>
<live>true</live>
<binding>

View File

@ -39,6 +39,11 @@ var RouteDialog = {
obj.calculateAltChangeAndTotals();
}));
# Set listener for Max altitude AGL value in route dialog for recalculate altitude change
append(obj.listeners, setlistener(obj.addonNodePath ~ "/addon-devel/route/wpts/max-alt-agl", func () {
obj.calculateAltChangeAndTotals();
}));
# Set listeners for distance fields for calculate altitude change
for (var i = 0; i < obj.maxRouteWaypoints; i += 1) {
append(obj.listeners, setlistener(obj.addonNodePath ~ "/addon-devel/route/wpts/wpt[" ~ i ~ "]/distance-m", func () {
@ -65,17 +70,26 @@ var RouteDialog = {
var totalDistance = 0.0;
var totalAlt = 0.0;
var isEnd = false;
var isAltLimit = false;
var isRouteMode = true;
var aircraft = Aircraft.getSelected(me.addon, isRouteMode);
# 0 means without altitude limits
var maxAltAgl = getprop(me.addonNodePath ~ "/addon-devel/route/wpts/max-alt-agl") or 0;
for (var i = 0; i < me.maxRouteWaypoints; i += 1) {
var distance = getprop(me.addonNodePath ~ "/addon-devel/route/wpts/wpt[" ~ i ~ "]/distance-m");
if (distance == nil) {
break;
var distance = getprop(me.addonNodePath ~ "/addon-devel/route/wpts/wpt[" ~ i ~ "]/distance-m") or 0;
# If we have reached the altitude limit, the altitude no longer changes (0)
var altChange = isAltLimit ? 0 : aircraft.getAltChange(distance);
if (maxAltAgl > 0 and altChange > 0 and totalAlt + altChange > maxAltAgl) {
# We will exceed the altitude limit, so set the altChange to the altitude limit
# and set isAltLimit flag that the limit is reached.
altChange = maxAltAgl - totalAlt;
isAltLimit = true;
}
var altChange = aircraft.getAltChange(distance);
setprop(me.addonNodePath ~ "/addon-devel/route/wpts/wpt[" ~ i ~ "]/alt-change-agl-ft", altChange);
if (!isEnd) {

View File

@ -47,7 +47,7 @@ var FlightPlan = {
#
# Get inital location of glider.
#
# Return object with "lat", "lon" and 'heading".
# Return object with "lat", "lon" and "heading".
#
getLocation: func () {
var icao = getprop("/sim/airport/closest-airport-id");
@ -137,6 +137,9 @@ var FlightPlan = {
var isGliderPos = false;
me.initAircraftVariable(location, isGliderPos);
# Max altitude without limits
setprop(me.addonNodePath ~ "/addon-devel/route/wpts/max-alt-agl", 0);
# inittial readonly waypoint
setprop(me.addonNodePath ~ "/addon-devel/route/init-wpt/heading-change", me.heading);
setprop(me.addonNodePath ~ "/addon-devel/route/init-wpt/distance-m", 100);
@ -245,23 +248,40 @@ var FlightPlan = {
me.addWptAir({"hdgChange": 0, "dist": 100 * aircraft.rolling}, {"elevationPlus": 3, "ktas": aircraft.speed * 1.05});
me.addWptAir({"hdgChange": 0, "dist": 100}, {"altChange": aircraft.vs / 10, "ktas": aircraft.speed * 1.025});
# 0 means without altitude limits
var maxAltAgl = getprop(me.addonNodePath ~ "/addon-devel/route/wpts/max-alt-agl") or 0;
var totalAlt = 0.0;
var isAltLimit = false;
# Add waypoints according to user settings
var speedInc = 1.0;
foreach (var wptNode; props.globals.getNode(me.addonNodePath ~ "/addon-devel/route/wpts").getChildren("wpt")) {
var dist = wptNode.getChild("distance-m").getValue();
if (dist <= 0.0) {
var distance = wptNode.getChild("distance-m").getValue();
if (distance <= 0.0) {
break;
}
var hdgChange = wptNode.getChild("heading-change").getValue();
var altChange = aircraft.getAltChange(dist);
speedInc += ((dist / Aircraft.DISTANCE_DETERMINANT) * 0.025);
# If we have reached the altitude limit, the altitude no longer changes (0)
var altChange = isAltLimit ? 0 : aircraft.getAltChange(distance);
if (maxAltAgl > 0 and altChange > 0 and totalAlt + altChange > maxAltAgl) {
# We will exceed the altitude limit, so set the altChange to the altitude limit
# and set isAltLimit flag that the limit is reached.
altChange = maxAltAgl - totalAlt;
isAltLimit = true;
}
speedInc += ((distance / Aircraft.DISTANCE_DETERMINANT) * 0.025);
var ktas = aircraft.speed * speedInc;
if (ktas > aircraft.speedLimit) {
ktas = aircraft.speedLimit;
}
me.addWptAir({"hdgChange": hdgChange, "dist": dist}, {"altChange": altChange, "ktas": ktas});
totalAlt += altChange;
me.addWptAir({"hdgChange": hdgChange, "dist": distance}, {"altChange": altChange, "ktas": ktas});
}
me.addWptEnd();