Completed wind store logic (not implemented in mcdu yet)
This commit is contained in:
parent
2fbdf96223
commit
79f8c543a1
7 changed files with 343 additions and 139 deletions
|
@ -4040,6 +4040,7 @@
|
|||
<file>Aircraft/A320-family/Nasal/FMGC/FMGC.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/FMGC/FMGC-b.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas</file>
|
||||
<file>Aircraft/A320-family/Nasal/FMGC/winds.nas</file>
|
||||
</fmgc>
|
||||
<mcdu>
|
||||
<file>Aircraft/A320-family/Nasal/MCDU/DUPLICATE.nas</file> <!-- dynamic page - init before others as used in various pages -->
|
||||
|
|
|
@ -722,6 +722,8 @@ var reset_FMGC = func {
|
|||
ITAF.init();
|
||||
FMGCinit();
|
||||
flightPlanController.reset();
|
||||
windController.reset();
|
||||
|
||||
mcdu.MCDU_reset(0);
|
||||
mcdu.MCDU_reset(1);
|
||||
setprop("it-autoflight/input/fd1", fd1);
|
||||
|
|
|
@ -29,21 +29,6 @@ var wpCourse = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course", 0, "
|
|||
var wpDistance = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance", 0, "DOUBLE")]];
|
||||
var wpCoursePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/course-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/course-from-prev", 0, "DOUBLE")]];
|
||||
var wpDistancePrev = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/distance-from-prev", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/distance-from-prev", 0, "DOUBLE")]];
|
||||
var wpWindDirection0 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[0]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[0]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[0]/direction", 0, "DOUBLE")]];
|
||||
var wpWindMagnitude0 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[0]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[0]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[0]/magnitude", 0, "DOUBLE")]];
|
||||
var wpWindAltitude0 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[0]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[0]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[0]/altitude", "", "STRING")]];
|
||||
|
||||
var wpWindDirection1 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[1]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[1]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[1]/direction", 0, "DOUBLE")]];
|
||||
var wpWindMagnitude1 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[1]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[1]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[1]/magnitude", 0, "DOUBLE")]];
|
||||
var wpWindAltitude1 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[1]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[1]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[1]/altitude", "", "STRING")]];
|
||||
|
||||
var wpWindDirection2 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[2]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[2]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[2]/direction", 0, "DOUBLE")]];
|
||||
var wpWindMagnitude2 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[2]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[2]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[2]/magnitude", 0, "DOUBLE")]];
|
||||
var wpWindAltitude2 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[2]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[2]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[2]/altitude", "", "STRING")]];
|
||||
|
||||
var wpWindDirection3 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[3]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[3]/direction", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[3]/direction", 0, "DOUBLE")]];
|
||||
var wpWindMagnitude3 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[3]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[3]/magnitude", 0, "DOUBLE")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[3]/magnitude", 0, "DOUBLE")]];
|
||||
var wpWindAltitude3 = [[props.globals.initNode("/FMGC/flightplan[0]/wp[0]/wind[3]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[1]/wp[0]/wind[3]/altitude", "", "STRING")], [props.globals.initNode("/FMGC/flightplan[2]/wp[0]/wind[3]/altitude", "", "STRING")]];
|
||||
|
||||
var flightPlanController = {
|
||||
flightplans: [createFlightplan(), createFlightplan(), createFlightplan(), nil],
|
||||
|
@ -108,6 +93,7 @@ var flightPlanController = {
|
|||
canvas_mcdu.myAirways[n].updateTmpy();
|
||||
}
|
||||
me.flightPlanChanged(n);
|
||||
fmgc.windController.createTemporaryWinds(n);
|
||||
},
|
||||
|
||||
loadFlightPlan: func(path) {
|
||||
|
@ -128,27 +114,6 @@ var flightPlanController = {
|
|||
me.flightplans[2] = me.flightplans[n].clone();
|
||||
me.flightPlanChanged(2);
|
||||
flightPlanTimer.start();
|
||||
|
||||
# copy winds since they are not part of the waypoint object
|
||||
for (var counter = 0; counter < me.flightplans[n].getPlanSize(); counter += 1) {
|
||||
wpWindDirection0[2][counter].setValue(wpWindDirection0[n][counter].getValue());
|
||||
wpWindMagnitude0[2][counter].setValue(wpWindMagnitude0[n][counter].getValue());
|
||||
wpWindAltitude0[2][counter].setValue(wpWindAltitude0[n][counter].getValue());
|
||||
|
||||
wpWindDirection1[2][counter].setValue(wpWindDirection1[n][counter].getValue());
|
||||
wpWindMagnitude1[2][counter].setValue(wpWindMagnitude1[n][counter].getValue());
|
||||
wpWindAltitude1[2][counter].setValue(wpWindAltitude1[n][counter].getValue());
|
||||
|
||||
wpWindDirection2[2][counter].setValue(wpWindDirection2[n][counter].getValue());
|
||||
wpWindMagnitude2[2][counter].setValue(wpWindMagnitude2[n][counter].getValue());
|
||||
wpWindAltitude2[2][counter].setValue(wpWindAltitude2[n][counter].getValue());
|
||||
|
||||
wpWindDirection3[2][counter].setValue(wpWindDirection3[n][counter].getValue());
|
||||
wpWindMagnitude3[2][counter].setValue(wpWindMagnitude3[n][counter].getValue());
|
||||
wpWindAltitude3[2][counter].setValue(wpWindAltitude3[n][counter].getValue());
|
||||
}
|
||||
|
||||
me.updateWind(n);
|
||||
}
|
||||
if (n == 3) { return; }
|
||||
me.resetFlightplan(n);
|
||||
|
@ -156,6 +121,7 @@ var flightPlanController = {
|
|||
if (canvas_mcdu.myDirTo[n] != nil) {
|
||||
canvas_mcdu.myDirTo[n].updateTmpy();
|
||||
}
|
||||
fmgc.windController.destroyTemporaryWinds(n, a);
|
||||
},
|
||||
|
||||
updateAirports: func(dep, arr, plan) {
|
||||
|
@ -169,6 +135,7 @@ var flightPlanController = {
|
|||
}
|
||||
|
||||
me.addDiscontinuity(1, plan);
|
||||
debug.dump(me.flightplans[2]);
|
||||
# reset mcdu if it exists
|
||||
if (canvas_mcdu.myFpln[0] != nil) { canvas_mcdu.myFpln[0].scroll = 0; }
|
||||
if (canvas_mcdu.myFpln[1] != nil) { canvas_mcdu.myFpln[1].scroll = 0; }
|
||||
|
@ -257,14 +224,17 @@ var flightPlanController = {
|
|||
if (DEBUG_DISCONT) { return; }
|
||||
if (force) {
|
||||
me.flightplans[plan].insertWP(createDiscontinuity(), index);
|
||||
fmgc.windController.insertWind(plan, index, 0, "DISCONTINUITY");
|
||||
}
|
||||
if (index > 0) {
|
||||
if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY" and me.flightplans[plan].getWP(index - 1).wp_name != "DISCONTINUITY") {
|
||||
me.flightplans[plan].insertWP(createDiscontinuity(), index);
|
||||
fmgc.windController.insertWind(plan, index, 0, "DISCONTINUITY");
|
||||
}
|
||||
} else {
|
||||
if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY") {
|
||||
me.flightplans[plan].insertWP(createDiscontinuity(), index);
|
||||
fmgc.windController.insertWind(plan, index, 0, "DISCONTINUITY");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -277,10 +247,12 @@ var flightPlanController = {
|
|||
|
||||
insertTP: func(n, index = 1) {
|
||||
me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "T-P"), index);
|
||||
fmgc.windController.insertWind(n, index, 0, "T-P");
|
||||
},
|
||||
|
||||
insertPPOS: func(n, index = 0) {
|
||||
me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), index);
|
||||
fmgc.windController.insertWind(n, index, 0, "PPOS");
|
||||
},
|
||||
|
||||
# childWPBearingDistance - return waypoint at bearing and distance from specified waypoint ghost
|
||||
|
@ -310,6 +282,7 @@ var flightPlanController = {
|
|||
|
||||
# fudge the altitude since we cannot create a hdgtoAlt from nasal. Assume 600 feet per mile - 2.5 miles
|
||||
me.flightplans[n].insertWP(createWP(me.childWPBearingDistance(wptStore, me.flightplans[n].departure_runway.heading, 2.5), "1500", "sid"), 1);
|
||||
fmgc.windController.insertWind(n, 1, 0, "1500");
|
||||
}
|
||||
me.flightPlanChanged(n);
|
||||
},
|
||||
|
@ -330,6 +303,7 @@ var flightPlanController = {
|
|||
hdg = hdg - 360;
|
||||
}
|
||||
me.flightplans[n].insertWP(createWP(me.childWPBearingDistance(wptStore, hdg, 5), "CF", "star"), me.arrivalIndex[n]);
|
||||
fmgc.windController.insertWind(n, me.arrivalIndex[n], 0, "CF");
|
||||
}
|
||||
me.flightPlanChanged(n);
|
||||
},
|
||||
|
@ -352,6 +326,7 @@ var flightPlanController = {
|
|||
# use createWP here as createWPFrom doesn't accept waypoints
|
||||
# createWPFrom worked before... but be sure!
|
||||
me.flightplans[plan].insertWP(createWP(waypointGhost, waypointGhost.wp_name), 2);
|
||||
fmgc.windController.insertWind(plan, 2, 0, waypointGhost.wp_name);
|
||||
me.addDiscontinuity(3, plan);
|
||||
} else {
|
||||
# we want to delete the intermediate waypoints up to but not including the waypoint. Leave index 0, we delete it later.
|
||||
|
@ -377,6 +352,7 @@ var flightPlanController = {
|
|||
if (((s == 0 and left(wp, 4) != FMGCdep.getValue() and left(wp, 4) != FMGCarr.getValue()) or (s == 1)) and me.flightplans[n].getPlanSize() > 2) {
|
||||
if (me.flightplans[n].getWP(index).id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one
|
||||
me.flightplans[n].deleteWP(index);
|
||||
fmgc.windController.deleteWind(n, index);
|
||||
if (me.flightplans[n].getWP(index) != nil and s == 0) {
|
||||
if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one
|
||||
me.addDiscontinuity(index, n);
|
||||
|
@ -384,6 +360,7 @@ var flightPlanController = {
|
|||
}
|
||||
} else {
|
||||
me.flightplans[n].deleteWP(index);
|
||||
fmgc.windController.deleteWind(n, index);
|
||||
}
|
||||
me.flightPlanChanged(n);
|
||||
canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed");
|
||||
|
@ -443,6 +420,7 @@ var flightPlanController = {
|
|||
var indexPresent = me.flightplans[plan].indexOfWP(airport[indexToInsert]);
|
||||
if (me.flightplans[plan].indexOfWP(airport[indexToInsert]) == -1) {
|
||||
me.flightplans[plan].insertWP(createWPFrom(airport[indexToInsert]), index);
|
||||
fmgc.windController.insertWind(plan, index, 0, text);
|
||||
me.addDiscontinuity(index + 1, plan);
|
||||
me.flightPlanChanged(plan);
|
||||
return 2;
|
||||
|
@ -476,6 +454,7 @@ var flightPlanController = {
|
|||
var indexPresent = me.flightplans[plan].indexOfWP(fix[indexToInsert]);
|
||||
if (me.flightplans[plan].indexOfWP(fix[indexToInsert]) == -1) {
|
||||
me.flightplans[plan].insertWP(createWPFrom(fix[indexToInsert]), index);
|
||||
fmgc.windController.insertWind(plan, index, 1, text);
|
||||
me.addDiscontinuity(index + 1, plan);
|
||||
me.flightPlanChanged(plan);
|
||||
return 2;
|
||||
|
@ -509,6 +488,7 @@ var flightPlanController = {
|
|||
var indexPresent = me.flightplans[plan].indexOfWP(navaid[indexToInsert]);
|
||||
if (me.flightplans[plan].indexOfWP(navaid[indexToInsert]) == -1) {
|
||||
me.flightplans[plan].insertWP(createWPFrom(navaid[indexToInsert]), index);
|
||||
fmgc.windController.insertWind(plan, index, 1, text);
|
||||
me.addDiscontinuity(index + 1, plan);
|
||||
me.flightPlanChanged(plan);
|
||||
return 2;
|
||||
|
@ -529,6 +509,7 @@ var flightPlanController = {
|
|||
if (me.flightplans[plan].indexOfWP(wpGhost) == -1) {
|
||||
# use createWP here as createWPFrom doesn't accept waypoints
|
||||
me.flightplans[plan].insertWP(createWP(wpGhost, wpGhost.wp_name), index);
|
||||
fmgc.windController.insertWind(plan, index, 1, wpGhost.wp_name);
|
||||
me.addDiscontinuity(index + 1, plan);
|
||||
me.flightPlanChanged(plan);
|
||||
return 2;
|
||||
|
@ -558,31 +539,12 @@ var flightPlanController = {
|
|||
}
|
||||
|
||||
me.flightplans[plan].insertWP(waypoint.wpGhost, index);
|
||||
fmgc.windController.insertWind(plan, index, 1, "LL");
|
||||
me.addDiscontinuity(index + 1, plan);
|
||||
me.flightPlanChanged(plan);
|
||||
return 2;
|
||||
},
|
||||
|
||||
getWaypointList: func(plan) {
|
||||
var waypointsList = [];
|
||||
for (var index = 1; index < me.arrivalIndex[plan]; index += 1) {
|
||||
if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY" and me.flightplans[plan].getWP(index).wp_type != "vectors" and me.flightplans[plan].getWP(index).wp_type != "hdgToAlt" and me.flightplans[plan].getWP(index).wp_type != "sid" and me.flightplans[plan].getWP(index).wp_type != "star" and me.flightplans[plan].getWP(index).wp_type != "approach") {
|
||||
append(waypointsList, me.flightplans[plan].getWP(index));
|
||||
}
|
||||
}
|
||||
return waypointsList;
|
||||
},
|
||||
|
||||
getWaypointMapping: func(plan) {
|
||||
var waypointsMapping = [];
|
||||
for (var index = 1; index < me.arrivalIndex[plan]; index += 1) {
|
||||
if (me.flightplans[plan].getWP(index).wp_name != "DISCONTINUITY" and me.flightplans[plan].getWP(index).wp_type != "vectors" and me.flightplans[plan].getWP(index).wp_type != "hdgToAlt" and me.flightplans[plan].getWP(index).wp_type != "sid" and me.flightplans[plan].getWP(index).wp_type != "star" and me.flightplans[plan].getWP(index).wp_type != "approach") {
|
||||
append(waypointsMapping, index);
|
||||
}
|
||||
}
|
||||
return waypointsMapping;
|
||||
},
|
||||
|
||||
# getWPforPBD - parse scratchpad text to find waypoint ghost for PBD
|
||||
# args: text, index, plan
|
||||
# text: scratchpad text
|
||||
|
@ -649,6 +611,37 @@ var flightPlanController = {
|
|||
return me.insertPlaceBearingDistance(wpGhost, textSplit[1] + localMagvar, textSplit[2], index, plan); # magnetic to true? I don't know. But this works!
|
||||
},
|
||||
|
||||
getNavCount: func(plan) {
|
||||
var count = 0;
|
||||
for (var wpt = 0; wpt < me.flightplans[plan].getPlanSize(); wpt += 1) {
|
||||
print(me.flightplans[plan].getWP(wpt).wp_type);
|
||||
if (me.flightplans[plan].getWP(wpt).wp_type == "navaid") {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
getDepartureCount: func(plan) {
|
||||
var count = 0;
|
||||
for (var wpt = 0; wpt < me.flightplans[plan].getPlanSize(); wpt += 1) {
|
||||
print(me.flightplans[plan].getWP(wpt).wp_role);
|
||||
if (me.flightplans[plan].getWP(wpt).wp_role == "sid") {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
getArrivalCount: func(plan) {
|
||||
var count = 0;
|
||||
for (var wpt = 0; wpt < me.flightplans[plan].getPlanSize(); wpt += 1) {
|
||||
if (me.flightplans[plan].getWP(wpt).wp_role == "star" or me.flightplans[plan].getWP(wpt).wp_role == "approach" or me.flightplans[plan].getWP(wpt).wp_role == "missed") {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
# insertPlaceBearingDistance - insert PBD waypoint at specified index,
|
||||
# at some specified bearing, distance from a specified location
|
||||
|
@ -665,6 +658,7 @@ var flightPlanController = {
|
|||
}
|
||||
|
||||
me.flightplans[plan].insertWP(waypoint.wpGhost, index);
|
||||
fmgc.windController.insertWind(plan, index, 0, "PBD");
|
||||
me.addDiscontinuity(index + 1, plan);
|
||||
me.flightPlanChanged(plan);
|
||||
return 2;
|
||||
|
@ -719,25 +713,10 @@ var flightPlanController = {
|
|||
append(wpDistance[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance", 0, "DOUBLE"));
|
||||
append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE"));
|
||||
append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE"));
|
||||
|
||||
append(wpWindDirection0[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[0]/direction", 0, "DOUBLE"));
|
||||
append(wpWindMagnitude0[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[0]/magnitude", 0, "DOUBLE"));
|
||||
append(wpWindAltitude0[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[0]/altitude", "", "STRING"));
|
||||
|
||||
append(wpWindDirection1[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[1]/direction", 0, "DOUBLE"));
|
||||
append(wpWindMagnitude1[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[1]/magnitude", 0, "DOUBLE"));
|
||||
append(wpWindAltitude1[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[1]/altitude", "", "STRING"));
|
||||
|
||||
append(wpWindDirection2[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[2]/direction", 0, "DOUBLE"));
|
||||
append(wpWindMagnitude2[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[2]/magnitude", 0, "DOUBLE"));
|
||||
append(wpWindAltitude2[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[2]/altitude", "", "STRING"));
|
||||
|
||||
append(wpWindDirection3[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[3]/direction", 0, "DOUBLE"));
|
||||
append(wpWindMagnitude3[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[3]/magnitude", 0, "DOUBLE"));
|
||||
append(wpWindAltitude3[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/wind[3]/altitude", "", "STRING"));
|
||||
}
|
||||
|
||||
me.updatePlans();
|
||||
me.updatePlans();
|
||||
fmgc.windController.updatePlans();
|
||||
|
||||
# push update to fuel
|
||||
if (getprop("/FMGC/internal/block-confirmed")) {
|
||||
|
@ -746,70 +725,6 @@ var flightPlanController = {
|
|||
}
|
||||
canvas_nd.A3XXRouteDriver.triggerSignal("fp-added");
|
||||
},
|
||||
|
||||
updateWind: func(n) {
|
||||
if (n == 0) {
|
||||
if (canvas_mcdu.myCLBWIND[0] != nil and canvas_mcdu.myCLBWIND[1] != nil) {
|
||||
canvas_mcdu.myCLBWIND[1].windList = canvas_mcdu.myCLBWIND[0].windList;
|
||||
canvas_mcdu.myCLBWIND[1]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myCRZWIND[0] != nil and canvas_mcdu.myCRZWIND[1] != nil) {
|
||||
if (!getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(0)) == 0) {
|
||||
canvas_mcdu.myCRZWIND[1].windList = canvas_mcdu.myCRZWIND[0].windList;
|
||||
} else {
|
||||
canvas_mcdu.myCRZWIND[1].del();
|
||||
canvas_mcdu.myCRZWIND[1] = nil;
|
||||
canvas_mcdu.myCRZWIND[1] = mcdu.windCRZPage.new(1, me.getWaypointList(2)[0], 0);
|
||||
}
|
||||
canvas_mcdu.myCRZWIND[1]._setupPageWithData();
|
||||
} else if (canvas_mcdu.myCRZWIND[1] != nil and getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(0)) > 0) {
|
||||
canvas_mcdu.myCRZWIND[1].del();
|
||||
canvas_mcdu.myCRZWIND[1] = nil;
|
||||
canvas_mcdu.myCRZWIND[1] = mcdu.windCRZPage.new(1, me.getWaypointList(2)[0], 0);
|
||||
canvas_mcdu.myCRZWIND[1]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myDESWIND[0] != nil and canvas_mcdu.myDESWIND[1] != nil) {
|
||||
canvas_mcdu.myDESWIND[1].windList = canvas_mcdu.myDESWIND[0].windList;
|
||||
canvas_mcdu.myDESWIND[1]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myHISTWIND[1] != nil) {
|
||||
canvas_mcdu.myHISTWIND[1]._setupPageWithData();
|
||||
}
|
||||
} else {
|
||||
if (canvas_mcdu.myCLBWIND[0] != nil and canvas_mcdu.myCLBWIND[1] != nil) {
|
||||
canvas_mcdu.myCLBWIND[0].windList = canvas_mcdu.myCLBWIND[1].windList;
|
||||
canvas_mcdu.myCLBWIND[0]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myCRZWIND[0] != nil and canvas_mcdu.myCRZWIND[1] != nil) {
|
||||
if (!getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(1)) == 0) {
|
||||
canvas_mcdu.myCRZWIND[0].windList = canvas_mcdu.myCRZWIND[1].windList;
|
||||
} else {
|
||||
canvas_mcdu.myCRZWIND[0].del();
|
||||
canvas_mcdu.myCRZWIND[0] = nil;
|
||||
canvas_mcdu.myCRZWIND[0] = mcdu.windCRZPage.new(0, me.getWaypointList(2)[0], 0);
|
||||
}
|
||||
canvas_mcdu.myCRZWIND[0]._setupPageWithData();
|
||||
} else if (canvas_mcdu.myCRZWIND[0] != nil and getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(1)) > 0) {
|
||||
canvas_mcdu.myCRZWIND[0].del();
|
||||
canvas_mcdu.myCRZWIND[0] = nil;
|
||||
canvas_mcdu.myCRZWIND[0] = mcdu.windCRZPage.new(0, me.getWaypointList(2)[0], 0);
|
||||
canvas_mcdu.myCRZWIND[0]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myDESWIND[0] != nil and canvas_mcdu.myDESWIND[1] != nil) {
|
||||
canvas_mcdu.myDESWIND[0].windList = canvas_mcdu.myDESWIND[1].windList;
|
||||
canvas_mcdu.myDESWIND[0]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myHISTWIND[0] != nil) {
|
||||
canvas_mcdu.myHISTWIND[0]._setupPageWithData();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updatePlans: func() {
|
||||
me.updateCurrentWaypoint();
|
||||
|
|
282
Nasal/FMGC/winds.nas
Normal file
282
Nasal/FMGC/winds.nas
Normal file
|
@ -0,0 +1,282 @@
|
|||
# A3XX FMGC Wind Driver
|
||||
# Copyright (c) 2020 Matthew Maring (mattmaring)
|
||||
|
||||
var wpDep = nil;
|
||||
var wpArr = nil;
|
||||
var pos = nil;
|
||||
var geoPosPrev = geo.Coord.new();
|
||||
var currentLegCourseDist = nil;
|
||||
var courseDistanceFrom = nil;
|
||||
var courseDistanceFromPrev = nil;
|
||||
var sizeWP = nil;
|
||||
var magTrueError = 0;
|
||||
var storeCourse = nil;
|
||||
|
||||
var DEBUG_DISCONT = 0;
|
||||
|
||||
# Props.getNode
|
||||
var magHDG = props.globals.getNode("/orientation/heading-magnetic-deg", 1);
|
||||
var trueHDG = props.globals.getNode("/orientation/heading-deg", 1);
|
||||
var FMGCdep = props.globals.getNode("/FMGC/internal/dep-arpt", 1);
|
||||
var FMGCarr = props.globals.getNode("/FMGC/internal/arr-arpt", 1);
|
||||
var toFromSet = props.globals.getNode("/FMGC/internal/tofrom-set", 1);
|
||||
|
||||
var wind = {
|
||||
new: func() {
|
||||
return {
|
||||
parents: [wind],
|
||||
heading: 0,
|
||||
magnitude: 0,
|
||||
altitude: 0
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var waypoint_winds = {
|
||||
type: "", #departure, waypoint, arrival
|
||||
includeWind: 1,
|
||||
wind1: 0,
|
||||
wind2: 0,
|
||||
wind3: 0,
|
||||
wind4: 0,
|
||||
wind5: 0,
|
||||
|
||||
new: func(id, type, includeWind) {
|
||||
me.id = id;
|
||||
me.type = type;
|
||||
me.includeWind = includeWind;
|
||||
return {
|
||||
id: me.id,
|
||||
type: me.type, #departure, waypoint, arrival
|
||||
includeWind: me.includeWind,
|
||||
wind1: wind.new(),
|
||||
wind2: wind.new(),
|
||||
wind3: wind.new(),
|
||||
wind4: wind.new(),
|
||||
wind5: wind.new()
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var windController = {
|
||||
winds: [[], [], []],
|
||||
nav_indicies: [[], [], []],
|
||||
windSizes: [0, 0, 0],
|
||||
#temporaryFlag: [0, 0],
|
||||
|
||||
init: func() {
|
||||
me.resetWind(2);
|
||||
#me.insertWind(2, 0, 1);
|
||||
#me.insertWind(2, 1, 0);
|
||||
# temp = waypoint_winds.new("KCVG", "waypoint", 1);
|
||||
# print(temp.wind2.magnitude);
|
||||
# temp.wind2.magnitude = 200;
|
||||
# print(temp.wind2.magnitude);
|
||||
},
|
||||
|
||||
reset: func() {
|
||||
#me.temporaryFlag[0] = 0;
|
||||
#me.temporaryFlag[1] = 0;
|
||||
me.resetWind(0);
|
||||
me.resetWind(1);
|
||||
me.resetWind(2);
|
||||
},
|
||||
|
||||
resetWind: func(n) {
|
||||
me.winds[n] = [];
|
||||
me.nav_indicies[n] = [];
|
||||
me.windSizes[n] = 0;
|
||||
},
|
||||
|
||||
createTemporaryWinds: func(n) {
|
||||
me.resetWind(n);
|
||||
me.winds[n] = me.winds[2];
|
||||
me.nav_indicies[n] = me.nav_indicies[2];
|
||||
me.windSizes[n] = me.windSizes[2];
|
||||
#me.temporaryFlag[n] = 1;
|
||||
},
|
||||
|
||||
destroyTemporaryWinds: func(n, a) { # a = 1 activate, a = 0 erase
|
||||
me.updatePlans();
|
||||
if (a == 1) {
|
||||
me.resetWind(2);
|
||||
me.winds[2] = me.winds[n];
|
||||
me.nav_indicies[2] = me.nav_indicies[n];
|
||||
me.windSizes[2] = me.windSizes[n];
|
||||
}
|
||||
if (n == 3) { return; }
|
||||
me.resetWind(n);
|
||||
#me.temporaryFlag[n] = 0;
|
||||
},
|
||||
|
||||
insertWind: func(plan, index, value, id) {
|
||||
if (me.windSizes[plan] == index) {
|
||||
if (value == 3) {
|
||||
append(me.winds[plan], waypoint_winds.new(id, "arrival", 0));
|
||||
} else if (value == 2) {
|
||||
append(me.winds[plan], waypoint_winds.new(id, "departure", 0));
|
||||
} else if (value == 1) {
|
||||
append(me.winds[plan], waypoint_winds.new(id, "waypoint", 1));
|
||||
} else {
|
||||
append(me.winds[plan], waypoint_winds.new(id, "waypoint", 0));
|
||||
}
|
||||
me.windSizes[plan] += 1;
|
||||
} else if (me.windSizes[plan] > index and index >= 0) {
|
||||
append(me.winds[plan], waypoint_winds.new(id, "waypoint", 0));
|
||||
me.windSizes[plan] += 1;
|
||||
for (i = me.windSizes[plan] - 1; i > index; i -= 1) {
|
||||
me.winds[plan][i] = me.winds[plan][i - 1];
|
||||
}
|
||||
if (value == 3) {
|
||||
me.winds[plan][index] = waypoint_winds.new(id, "arrival", 0);
|
||||
} else if (value == 2) {
|
||||
me.winds[plan][index] = waypoint_winds.new(id, "departure", 0);
|
||||
} else if (value == 1) {
|
||||
me.winds[plan][index] = waypoint_winds.new(id, "waypoint", 1);
|
||||
} else {
|
||||
me.winds[plan][index] = waypoint_winds.new(id, "waypoint", 0);
|
||||
}
|
||||
} else {
|
||||
print("insert invalid id: ", id, ", plan: ", plan, ", index: ", index, ", size: ", me.windSizes[plan]);
|
||||
debug.dump(me.winds);
|
||||
debug.dump(me.windSizes);
|
||||
return;
|
||||
}
|
||||
print("insert plan: ", plan, ", index: ", index);
|
||||
debug.dump(me.winds);
|
||||
debug.dump(me.windSizes);
|
||||
},
|
||||
|
||||
deleteWind: func(plan, index) {
|
||||
if (me.windSizes[plan] == index) {
|
||||
pop(me.winds[plan]);
|
||||
me.windSizes[plan] -= 1;
|
||||
} else if (me.windSizes[plan] > index and index >= 0) {
|
||||
for (i = index; i < me.windSizes[plan] - 1; i += 1) {
|
||||
me.winds[plan][i] = me.winds[plan][i + 1];
|
||||
}
|
||||
pop(me.winds[plan]);
|
||||
me.windSizes[plan] -= 1;
|
||||
} else {
|
||||
print("delete invalid plan: ", plan, ", index: ", index, ", size: ", me.windSizes[plan]);
|
||||
debug.dump(me.winds);
|
||||
debug.dump(me.windSizes);
|
||||
return;
|
||||
}
|
||||
print("delete plan: ", plan, ", index: ", index);
|
||||
debug.dump(me.winds);
|
||||
debug.dump(me.windSizes);
|
||||
},
|
||||
|
||||
updatePlans: func() {
|
||||
var winds_copy = me.winds;
|
||||
var windSizes_copy = me.windSizes;
|
||||
me.winds = [[], [], []];
|
||||
me.nav_indicies = [[], [], []];
|
||||
me.windSizes = [0, 0, 0];
|
||||
# loop through waypoints
|
||||
for (plan = 0; plan <= 2; plan += 1) {
|
||||
for (i = 0; i < fmgc.flightPlanController.flightplans[plan].getPlanSize(); i += 1) {
|
||||
var waypoint = fmgc.flightPlanController.flightplans[plan].getWP(i);
|
||||
print(waypoint.wp_role, "| : |", waypoint.wp_type);
|
||||
if (waypoint.wp_role == "sid") {
|
||||
append(me.winds[plan], waypoint_winds.new(waypoint.id, "departure", 0));
|
||||
me.windSizes[plan] += 1;
|
||||
} else if (waypoint.wp_role == "star" or waypoint.wp_role == "arrival" or waypoint.wp_role == "missed") {
|
||||
append(me.winds[plan], waypoint_winds.new(waypoint.id, "arrival", 0));
|
||||
me.windSizes[plan] += 1;
|
||||
} else if (waypoint.wp_role == nil and waypoint.wp_type == "navaid") {
|
||||
var found = 0;
|
||||
for (index = 0; index < windSizes_copy[plan]; index += 1) {
|
||||
print(waypoint.id, " : ", winds_copy[plan][index].id);
|
||||
if (waypoint.id == winds_copy[plan][index].id) {
|
||||
append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 1));
|
||||
append(me.nav_indicies[plan], i);
|
||||
me.windSizes[plan] += 1;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
if (found != 1) {
|
||||
append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 0));
|
||||
me.windSizes[plan] += 1;
|
||||
}
|
||||
} else {
|
||||
append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 0));
|
||||
me.windSizes[plan] += 1;
|
||||
}
|
||||
print("insert plan: ", plan, ", index: ", i);
|
||||
debug.dump(me.winds);
|
||||
debug.dump(me.nav_indicies);
|
||||
debug.dump(me.windSizes);
|
||||
}
|
||||
}
|
||||
|
||||
me.updateWind(0);
|
||||
me.updateWind(1);
|
||||
me.updateWind(2);
|
||||
},
|
||||
|
||||
updateWind: func(n) {
|
||||
if (n == 0) {
|
||||
if (canvas_mcdu.myCLBWIND[0] != nil and canvas_mcdu.myCLBWIND[1] != nil) {
|
||||
canvas_mcdu.myCLBWIND[1].windList = canvas_mcdu.myCLBWIND[0].windList;
|
||||
canvas_mcdu.myCLBWIND[1]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myCRZWIND[0] != nil and canvas_mcdu.myCRZWIND[1] != nil) {
|
||||
if (!getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(0)) == 0) {
|
||||
canvas_mcdu.myCRZWIND[1].windList = canvas_mcdu.myCRZWIND[0].windList;
|
||||
} else {
|
||||
canvas_mcdu.myCRZWIND[1].del();
|
||||
canvas_mcdu.myCRZWIND[1] = nil;
|
||||
canvas_mcdu.myCRZWIND[1] = mcdu.windCRZPage.new(1, me.getWaypointList(2)[0], 0);
|
||||
}
|
||||
canvas_mcdu.myCRZWIND[1]._setupPageWithData();
|
||||
} else if (canvas_mcdu.myCRZWIND[1] != nil and getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(0)) > 0) {
|
||||
canvas_mcdu.myCRZWIND[1].del();
|
||||
canvas_mcdu.myCRZWIND[1] = nil;
|
||||
canvas_mcdu.myCRZWIND[1] = mcdu.windCRZPage.new(1, me.getWaypointList(2)[0], 0);
|
||||
canvas_mcdu.myCRZWIND[1]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myDESWIND[0] != nil and canvas_mcdu.myDESWIND[1] != nil) {
|
||||
canvas_mcdu.myDESWIND[1].windList = canvas_mcdu.myDESWIND[0].windList;
|
||||
canvas_mcdu.myDESWIND[1]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myHISTWIND[1] != nil) {
|
||||
canvas_mcdu.myHISTWIND[1]._setupPageWithData();
|
||||
}
|
||||
} else {
|
||||
if (canvas_mcdu.myCLBWIND[0] != nil and canvas_mcdu.myCLBWIND[1] != nil) {
|
||||
canvas_mcdu.myCLBWIND[0].windList = canvas_mcdu.myCLBWIND[1].windList;
|
||||
canvas_mcdu.myCLBWIND[0]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myCRZWIND[0] != nil and canvas_mcdu.myCRZWIND[1] != nil) {
|
||||
if (!getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(1)) == 0) {
|
||||
canvas_mcdu.myCRZWIND[0].windList = canvas_mcdu.myCRZWIND[1].windList;
|
||||
} else {
|
||||
canvas_mcdu.myCRZWIND[0].del();
|
||||
canvas_mcdu.myCRZWIND[0] = nil;
|
||||
canvas_mcdu.myCRZWIND[0] = mcdu.windCRZPage.new(0, me.getWaypointList(2)[0], 0);
|
||||
}
|
||||
canvas_mcdu.myCRZWIND[0]._setupPageWithData();
|
||||
} else if (canvas_mcdu.myCRZWIND[0] != nil and getprop("/FMGC/internal/tofrom-set") and size(me.getWaypointList(1)) > 0) {
|
||||
canvas_mcdu.myCRZWIND[0].del();
|
||||
canvas_mcdu.myCRZWIND[0] = nil;
|
||||
canvas_mcdu.myCRZWIND[0] = mcdu.windCRZPage.new(0, me.getWaypointList(2)[0], 0);
|
||||
canvas_mcdu.myCRZWIND[0]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myDESWIND[0] != nil and canvas_mcdu.myDESWIND[1] != nil) {
|
||||
canvas_mcdu.myDESWIND[0].windList = canvas_mcdu.myDESWIND[1].windList;
|
||||
canvas_mcdu.myDESWIND[0]._setupPageWithData();
|
||||
}
|
||||
|
||||
if (canvas_mcdu.myHISTWIND[0] != nil) {
|
||||
canvas_mcdu.myHISTWIND[0]._setupPageWithData();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -207,6 +207,7 @@ var systemsInit = func {
|
|||
systems.fire_init();
|
||||
systems.icingInit();
|
||||
fmgc.flightPlanController.reset();
|
||||
fmgc.windController.reset();
|
||||
fadec.FADEC.init();
|
||||
fmgc.ITAF.init();
|
||||
fmgc.FMGCinit();
|
||||
|
@ -225,6 +226,7 @@ var systemsInit = func {
|
|||
fcu.FCUController.init();
|
||||
dmc.DMController.init();
|
||||
fmgc.flightPlanController.init();
|
||||
fmgc.windController.init();
|
||||
}
|
||||
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
|
|
|
@ -169,7 +169,9 @@ var initInputA = func(key, i) {
|
|||
setprop("/FMGC/internal/fuel-calculating", 1);
|
||||
}
|
||||
fmgc.flightPlanController.reset(2);
|
||||
fmgc.windController.reset(2);
|
||||
fmgc.flightPlanController.init();
|
||||
fmgc.windController.init();
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
#} else if (scratchpad == "") {
|
||||
#setprop("/FMGC/internal/alt-selected", 0);
|
||||
|
|
|
@ -70,10 +70,10 @@ var windCRZPage = {
|
|||
|
||||
# load wind list
|
||||
if (me.singleCRZ == 0) {
|
||||
if (fmgc.flightPlanController.temporaryFlag[me.computer]) {
|
||||
if (fmgc.windController.temporaryFlag[me.computer]) {
|
||||
#get from 0
|
||||
me.windList = [nil];
|
||||
if (fmgc.wpWindAltitude0[me.computer][me.match_location].getValue() != "") {
|
||||
if (fmgc.windController.winds[me.computer][me.match_location].getValue() != nil) {
|
||||
me.windList[0] = [fmgc.wpWindDirection0[me.computer][me.match_location].getValue(), fmgc.wpWindMagnitude0[me.computer][me.match_location].getValue(), fmgc.wpWindAltitude0[me.computer][me.match_location].getValue()];
|
||||
append(me.windList, nil);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue