1
0
Fork 0

INITA loading

This commit is contained in:
legoboyvdlp R 2020-08-01 16:30:16 +01:00
parent fc25237eb2
commit fb41cf8424
5 changed files with 96 additions and 25 deletions

View file

@ -45,7 +45,11 @@
</text>
<text>
<halign>left</halign>
<label>3. Please enter your username in the following dialog box (not case sensitive)</label>
<label>3. GIGO... there is no sanity check on inputs!</label>
</text>
<text>
<halign>left</halign>
<label>4. Please enter your username in the following dialog box (not case sensitive)</label>
</text>
<group>
<layout>hbox</layout>

View file

@ -224,6 +224,28 @@ var updateARPT = func {
}
}
var updateArptLatLon = func {
#ref lat
dms = getprop("/FMGC/flightplan[2]/wp[0]/lat");
degrees = int(dms);
minutes = sprintf("%.1f",abs((dms - degrees) * 60));
sign = degrees >= 0 ? "N" : "S";
setprop("/FMGC/internal/align-ref-lat-degrees", degrees);
setprop("/FMGC/internal/align-ref-lat-minutes", minutes);
setprop("/FMGC/internal/align-ref-lat-sign", sign);
#ref long
dms = getprop("/FMGC/flightplan[2]/wp[0]/lon");
degrees = int(dms);
minutes = sprintf("%.1f",abs((dms - degrees) * 60));
sign = degrees >= 0 ? "E" : "W";
setprop("/FMGC/internal/align-ref-long-degrees", degrees);
setprop("/FMGC/internal/align-ref-long-minutes", minutes);
setprop("/FMGC/internal/align-ref-long-sign", sign);
#ref edit
setprop("/FMGC/internal/align-ref-lat-edit", 0);
setprop("/FMGC/internal/align-ref-long-edit", 0);
}
updateRouteManagerAlt = func() {
setprop("autopilot/route-manager/cruise/altitude-ft", FMGCInternal.crzFt);
};

View file

@ -3,13 +3,16 @@
var SimbriefParser = {
node: nil,
OFP: nil,
store1: nil,
store2: nil,
inhibit: 0,
fetch: func(username, i) {
me.inhibit = 1;
var stamp = systime();
http.save("https://www.simbrief.com/api/xml.fetcher.php?username=" ~ username, getprop('/sim/fg-home') ~ "/Export/simbrief" ~ stamp ~ ".xml")
.fail(func mcdu.mcdu_message(i, "SIMBRIEF FAILED"))
.done(func me.read(getprop('/sim/fg-home') ~ "/Export/simbrief" ~ stamp ~ ".xml"), 1);
.done(func me.read(getprop('/sim/fg-home') ~ "/Export/simbrief" ~ stamp ~ ".xml", i));
},
read: func(xml, i) {
var data = io.readxml(xml);
@ -18,10 +21,65 @@ var SimbriefParser = {
print("XML file " ~ xml ~ " not a valid Simbrief file");
} else {
me.node = data;
me.parseOFP();
mcdu.mcdu_message(i, "AOC ACT F-PLN UPLINK");
}
} else {
print("Error reading " ~ xml);
}
},
parseOFP: func() {
me.OFP = me.node.getChild("OFP");
me.store1 = nil;
me.store2 = nil;
me.store1 = me.OFP.getChild("general");
me.store2 = me.OFP.getChild("alternate");
fmgc.FMGCInternal.flightNum = me.store1.getChild("icao_airline").getValue() ~ me.store1.getChild("flight_number").getValue();
fmgc.FMGCInternal.flightNumSet = 1;
fmgc.FMGCInternal.costIndex = me.store1.getChild("costindex").getValue();
fmgc.FMGCInternal.costIndexSet = 1;
fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex);
fmgc.FMGCInternal.tropo = me.store1.getChild("avg_tropopause").getValue();
fmgc.FMGCInternal.tropoSet = 1;
fmgc.FMGCInternal.crzFt = me.store1.getChild("initial_altitude").getValue();
fmgc.FMGCInternal.crzFl = me.store1.getChild("initial_altitude").getValue() / 100;
fmgc.altvert();
fmgc.FMGCInternal.crzSet = 1;
mcdu.updateCrzLvlCallback();
fmgc.FMGCInternal.crzTemp = (((me.store1.getChild("initial_altitude").getValue() / 1000) * -2) + 15) + me.store1.getChild("avg_temp_dev").getValue();
fmgc.FMGCInternal.crzTempSet = 1;
fmgc.FMGCInternal.crzProg = me.store1.getChild("initial_altitude").getValue() / 100;
fmgc.FMGCInternal.altAirport = me.store2.getChild("icao_code").getValue();
fmgc.FMGCInternal.altAirportSet = 1;
# Flightplan stuff
fmgc.flightPlanController.flightplans[3] = createFlightplan();
# INITA
me.store1 = me.OFP.getChild("origin");
me.store2 = me.OFP.getChild("destination");
fmgc.FMGCInternal.depApt = me.store1.getChild("icao_code").getValue();
fmgc.FMGCInternal.arrApt = me.store2.getChild("icao_code").getValue();
fmgc.FMGCInternal.toFromSet = 1;
fmgc.FMGCNodes.toFromSet.setValue(1);
fmgc.flightPlanController.flightplans[3].departure = airportinfo(fmgc.FMGCInternal.depApt);
fmgc.flightPlanController.flightplans[3].destination = airportinfo(fmgc.FMGCInternal.arrApt);
fmgc.FMGCInternal.altSelected = 0;
fmgc.updateArptLatLon();
fmgc.updateARPT();
fmgc.flightPlanController.destroyTemporaryFlightPlan(3, 1);
fmgc.windController.updatePlans();
fmgc.updateRouteManagerAlt();
if (getprop("/FMGC/internal/block-confirmed")) {
setprop("/FMGC/internal/fuel-calculating", 0);
setprop("/FMGC/internal/fuel-calculating", 1);
}
},
};

View file

@ -167,7 +167,6 @@ var flightPlanController = {
me.currentToWptIndex.setValue(0);
me.arrivalIndex = [0, 0, 0]; # reset arrival index calculations
}
me.addDiscontinuity(1, plan);
# reset mcdu if it exists
if (canvas_mcdu.myFpln[0] != nil) { canvas_mcdu.myFpln[0].scroll = 0; }

View file

@ -211,25 +211,7 @@ var initInputA = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
fmgc.flightPlanController.updateAirports(fromto[0], fromto[1], 2);
fmgc.FMGCInternal.altSelected = 0;
#ref lat
dms = getprop("/FMGC/flightplan[2]/wp[0]/lat");
degrees = int(dms);
minutes = sprintf("%.1f",abs((dms - degrees) * 60));
sign = degrees >= 0 ? "N" : "S";
setprop("/FMGC/internal/align-ref-lat-degrees", degrees);
setprop("/FMGC/internal/align-ref-lat-minutes", minutes);
setprop("/FMGC/internal/align-ref-lat-sign", sign);
#ref long
dms = getprop("/FMGC/flightplan[2]/wp[0]/lon");
degrees = int(dms);
minutes = sprintf("%.1f",abs((dms - degrees) * 60));
sign = degrees >= 0 ? "E" : "W";
setprop("/FMGC/internal/align-ref-long-degrees", degrees);
setprop("/FMGC/internal/align-ref-long-minutes", minutes);
setprop("/FMGC/internal/align-ref-long-sign", sign);
#ref edit
setprop("/FMGC/internal/align-ref-lat-edit", 0);
setprop("/FMGC/internal/align-ref-long-edit", 0);
fmgc.updateArptLatLon();
#setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION");
} else {
mcdu_message(i, "NOT ALLOWED");
@ -242,10 +224,16 @@ var initInputA = func(key, i) {
}
}
} else if (key == "R2") {
if (getprop("/FMGC/simbrief-username") == "") {
mcdu.mcdu_message(i, "MISSING USERNAME")
if (getprop("engines/engine[0]/state") != 3 and getprop("engines/engine[1]/state") != 3) {
if (getprop("/FMGC/simbrief-username") == "") {
mcdu.mcdu_message(i, "MISSING USERNAME")
} elsif (!Simbrief.SimbriefParser.inhibit) {
Simbrief.SimbriefParser.fetch(getprop("/FMGC/simbrief-username"), i);
} else {
mcdu_message(i, "NOT ALLOWED");
}
} else {
Simbrief.SimbriefParser.fetch(getprop("/FMGC/simbrief-username"), i);
mcdu_message(i, "NOT ALLOWED");
}
} else if (key == "R3") {
setprop("MCDU[" ~ i ~ "]/page", "IRSINIT");